diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3dad601..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Config file for automatic testing at travis-ci.org - -language: python - -python: - - "3.4" - - "3.3" - - "2.7" - - "2.6" - - "pypy" - -# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -install: pip install -r requirements.txt - -# command to run tests, e.g. python setup.py test -script: python setup.py test diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index b7cf1b7..59f6840 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -74,38 +74,21 @@ Ready to contribute? Here's how to set up `pysysgit` for local development. Now you can make your changes locally. -5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: - - $ flake8 sysgit tests - $ python setup.py test - $ tox - - To get flake8 and tox, just pip install them into your virtualenv. - -6. Commit your changes and push your branch to GitHub:: +5. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature -7. Submit a pull request through the GitHub website. +6. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: -1. The pull request should include tests. -2. If the pull request adds functionality, the docs should be updated. Put +1. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check - https://travis-ci.org/onlynone/pysysgit/pull_requests - and make sure that the tests pass for all supported Python versions. - -Tips ----- - -To run a subset of tests:: +2. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. - $ python -m unittest tests.test_sysgit diff --git a/MANIFEST.in b/MANIFEST.in index 2bb6bb1..89b5c85 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,6 @@ include HISTORY.rst include LICENSE include README.rst -recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] diff --git a/Makefile b/Makefile deleted file mode 100644 index 46c958a..0000000 --- a/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -.PHONY: clean-pyc clean-build docs clean - -help: - @echo "clean - remove all build, test, coverage and Python artifacts" - @echo "clean-build - remove build artifacts" - @echo "clean-pyc - remove Python file artifacts" - @echo "clean-test - remove test and coverage artifacts" - @echo "lint - check style with flake8" - @echo "test - run tests quickly with the default Python" - @echo "test-all - run tests on every Python version with tox" - @echo "coverage - check code coverage quickly with the default Python" - @echo "docs - generate Sphinx HTML documentation, including API docs" - @echo "release - package and upload a release" - @echo "dist - package" - @echo "install - install the package to the active Python's site-packages" - -clean: clean-build clean-pyc clean-test - -clean-build: - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - find . -name '*.egg-info' -exec rm -fr {} + - find . -name '*.egg' -exec rm -f {} + - -clean-pyc: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -fr {} + - -clean-test: - rm -fr .tox/ - rm -f .coverage - rm -fr htmlcov/ - -lint: - flake8 sysgit tests - -test: - python setup.py test - -test-all: - tox - -coverage: - coverage run --source sysgit setup.py test - coverage report -m - coverage html - open htmlcov/index.html - -docs: - rm -f docs/sysgit.rst - rm -f docs/modules.rst - sphinx-apidoc -o docs/ sysgit - $(MAKE) -C docs clean - $(MAKE) -C docs html - open docs/_build/html/index.html - -release: clean - python setup.py sdist upload - python setup.py bdist_wheel upload - -dist: clean - python setup.py sdist - python setup.py bdist_wheel - ls -l dist - -install: clean - python setup.py install diff --git a/setup.py b/setup.py index 09dcc11..e1acebe 100755 --- a/setup.py +++ b/setup.py @@ -18,10 +18,6 @@ # TODO: put package requirements here ] -test_requirements = [ - # TODO: put package test requirements here -] - setup( name='sysgit', version='0.1.0', @@ -52,6 +48,4 @@ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', ], - test_suite='tests', - tests_require=test_requirements ) diff --git a/sysgit/__init__.py b/sysgit/__init__.py index 1c3c609..91ecdce 100755 --- a/sysgit/__init__.py +++ b/sysgit/__init__.py @@ -3,3 +3,7 @@ __author__ = 'Steven Willis' __email__ = 'onlynone@gmail.com' __version__ = '0.1.0' + +__all__ = ["git"] + +from .utils import git diff --git a/sysgit/sysgit.py b/sysgit/sysgit.py deleted file mode 100755 index 40a96af..0000000 --- a/sysgit/sysgit.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/sysgit/utils.py b/sysgit/utils.py new file mode 100644 index 0000000..f4fe227 --- /dev/null +++ b/sysgit/utils.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +import os +import errno +import subprocess + +__all__ = ["mkdir_p", "touch", "git", "CALL", "CHECK_CALL", "CHECK_OUTPUT"] + +CALL = 'call' +CHECK_CALL = 'check_call' +CHECK_OUTPUT = 'check_output' + +__sub_calls = { + CALL: subprocess.call, + CHECK_CALL: subprocess.check_call, + CHECK_OUTPUT: subprocess.check_output + } + +__default_subprocess_kwargs = { + 'close_fds': True, + 'shell': False, + } + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + +def touch(fname, times=None): + with open(fname, 'a'): + os.utime(fname, times) + + +def git(*args, **kwargs): + """Execute git commands + + Args: + *args: The positional arguments are used as arguments to the git + command. For example, the following python code: + + git("commit", "--help") + + would execute: + + git commit --help + + f: One of CALL, CHECK_CALL, or CHECK_OUTPUT. Corresponds to the function + from the subprocess module called to execute git. Defaults to CHECK_CALL + + **kwargs: The keyword arguments are passed through to the subprocess + function as-is. + + Returns: + Whatever is returned by the respective subprocess function. For example, + f=CALL would return the returncode attribute, and f=CHECK_OUTPUT would + return the content of stdout. + + Exmples: + The following call: + + git("commit", "-m", "Commit Message", cwd="/path/to/repo") + + results in: + + subprocess.check_call(["git", "commit", "-m", "Commit Message"], cwd="/path/to/repo") + + And: + + git("checkout", "-b", "branch_name", f=CHECK_OUTPUT, cwd="/path/to/repo") + + results in: + + subprocess.check_output(["git", "checkout", "-b", "branch_name"], cwd="/path/to/repo") + + + """ + + f = kwargs.pop('f', CHECK_CALL) + f = __sub_calls[f] + + full_args = ("git",) + tuple(args) + + full_kwargs = __default_subprocess_kwargs.copy() + full_kwargs.update(kwargs) + + return f(full_args, **full_kwargs) diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100755 index 40a96af..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/test_sysgit.py b/tests/test_sysgit.py deleted file mode 100755 index 4e960a6..0000000 --- a/tests/test_sysgit.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -test_sysgit ----------------------------------- - -Tests for `sysgit` module. -""" - -import unittest - -from sysgit import sysgit - - -class TestSysgit(unittest.TestCase): - - def setUp(self): - pass - - def test_something(self): - pass - - def tearDown(self): - pass - -if __name__ == '__main__': - unittest.main()