Add autopep8 git commit hook (#671)

* Add autopep git hook

* Fix broken link
This commit is contained in:
Markus Unterwaditzer 2017-09-23 13:55:57 +02:00 committed by GitHub
parent e2583ededf
commit 9314a93d67
4 changed files with 23 additions and 16 deletions

View file

@ -16,7 +16,8 @@ export DETERMINISTIC_TESTS := false
export ETESYNC_TESTS := false
# Assume to run in Travis. Don't use this outside of a virtual machine. It will
# heavily "pollute" your system.
# heavily "pollute" your system, such as attempting to install a new Python
# systemwide.
export CI := false
# Whether to generate coverage data while running tests.
@ -79,7 +80,7 @@ install-test: install-servers
[ -z "$(TEST_EXTRA_PACKAGES)" ] || pip install $(TEST_EXTRA_PACKAGES)
install-style: install-docs
pip install flake8 flake8-import-order flake8-bugbear>=17.3.0
pip install flake8 flake8-import-order 'flake8-bugbear>=17.3.0' autopep8
style:
flake8
@ -97,9 +98,6 @@ install-docs:
docs:
cd docs && make html
sh: # open subshell with default test config
$$SHELL;
linkcheck:
sphinx-build -W -b linkcheck ./docs/ ./docs/_build/linkcheck/
@ -113,7 +111,7 @@ release-deb:
sh scripts/release-deb.sh ubuntu xenial
sh scripts/release-deb.sh ubuntu zesty
install-dev:
install-dev: install-git-hooks
pip install -e .
[ "$(ETESYNC_TESTS)" = "false" ] || pip install -e .[etesync]
set -xe && if [ "$(REQUIREMENTS)" = "devel" ]; then \
@ -124,6 +122,13 @@ install-dev:
pip install -U --force-reinstall $$(python setup.py --quiet minimal_requirements); \
fi
install-git-hooks: install-style
echo "make style-autocorrect" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
style-autocorrect:
git diff --cached --name-only | egrep '\.py$$' | xargs --no-run-if-empty autopep8 -ri
ssh-submodule-urls:
git submodule foreach "\
echo -n 'Old: '; \

View file

@ -174,9 +174,8 @@ To use this storage type, you need to install some additional dependencies::
pip install vdirsyncer[google]
Furthermore you need to register vdirsyncer as an application yourself to
obtain ``client_id`` and ``client_secret``, as `it is against Google's Terms of
Service to hardcode those into opensource software
<https://developers.google.com/terms/?hl=th#b-confidential-matters>`_:
obtain ``client_id`` and ``client_secret``, as it is against Google's Terms of
Service to hardcode those into opensource software [googleterms]_:
1. Go to the `Google API Manager <https://console.developers.google.com>`_ and
create a new project under any name.
@ -198,6 +197,9 @@ The ``token_file`` parameter should be a filepath where vdirsyncer can later
store authentication-related data. You do not need to create the file itself
or write anything to it.
.. [googleterms] See `ToS <https://developers.google.com/terms/?hl=th>`_,
section "Confidential Matters".
.. note::
You need to configure which calendars Google should offer vdirsyncer using

View file

@ -79,19 +79,19 @@ For many patches, it might suffice to just let Travis run the tests. However,
Travis is slow, so you might want to run them locally too. For this, set up a
virtualenv_ and run this inside of it::
# install vdirsyncer from the repo into the virtualenv. Prerequisite for
# most other tasks.
# install:
# - vdirsyncer from the repo into the virtualenv
# - stylecheckers (flake8) and code formatters (autopep8)
# - git commit hook for autopep8
make install-dev
make install-test # install test dependencies
make install-style # install dependencies for stylechecking
make install-docs # install dependencies for building documentation
Then you can run::
make test # The normal testsuite
make test # The normal testsuite
make style # Stylechecker
make docs # Build the HTML docs, output is at docs/_build/html/
make docs # Build the HTML docs, output is at docs/_build/html/
The ``Makefile`` has a lot of options that allow you to control which tests are
run, and which servers are tested. Take a look at its code where they are all

View file

@ -17,7 +17,7 @@ from vdirsyncer.vobject import Item
from .. import StorageTests, get_server_mixin
dav_server = os.environ['DAV_SERVER']
dav_server = os.environ.get('DAV_SERVER', 'skip')
ServerMixin = get_server_mixin(dav_server)