diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2015-07-12 20:05:29 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2015-07-12 20:05:29 +0200 |
commit | f4b2c251e2a1a0e0494972186e7dbc9f02b3c84d (patch) | |
tree | b9145170bd7c2fcaabe71c3fcfed60f27775f5d0 | |
parent | f6a451a861c8075e4029c467a03ba80ed1870532 (diff) | |
download | raven-f4b2c251e2a1a0e0494972186e7dbc9f02b3c84d.tar.gz |
Split up hooks
m--------- | docs/_sentryext | 0 | ||||
-rwxr-xr-x | hooks/pre-commit | 51 | ||||
-rwxr-xr-x | hooks/pre-commit.flake8 | 39 | ||||
l--------- | hooks/pre-commit.verify-docs | 1 |
4 files changed, 52 insertions, 39 deletions
diff --git a/docs/_sentryext b/docs/_sentryext -Subproject ce0441713dd7588fb320bf363f1d2cbbab05267 +Subproject 2210ebed81f91aabd730bf5f7224a0fdfee58d2 diff --git a/hooks/pre-commit b/hooks/pre-commit index d58db4d..245c4b7 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,39 +1,12 @@ -#!/usr/bin/env python - -import glob -import os -import sys - -os.environ['PYFLAKES_NODOCTEST'] = '1' - -# pep8.py uses sys.argv to find setup.cfg -sys.argv = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)] - -# git usurbs your bin path for hooks and will always run system python -if 'VIRTUAL_ENV' in os.environ: - site_packages = glob.glob( - '%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0] - sys.path.insert(0, site_packages) - - -def main(): - from flake8.main import DEFAULT_CONFIG - from flake8.engine import get_style_guide - from flake8.hooks import run - - gitcmd = "git diff-index --cached --name-only HEAD" - - _, files_modified, _ = run(gitcmd) - - # remove non-py files and files which no longer exist - files_modified = filter( - lambda x: x.endswith('.py') and os.path.exists(x), - files_modified) - - flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG) - report = flake8_style.check_files(files_modified) - - return report.total_errors - -if __name__ == '__main__': - sys.exit(main()) +#!/bin/bash + +failed=0 +for filename in hooks/pre-commit.*; do + if [ -f "hooks/$filename" ]; then + if $("./hooks/$filename") != "0"; then + failed=1 + fi + fi +done + +exit failed diff --git a/hooks/pre-commit.flake8 b/hooks/pre-commit.flake8 new file mode 100755 index 0000000..d58db4d --- /dev/null +++ b/hooks/pre-commit.flake8 @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +import glob +import os +import sys + +os.environ['PYFLAKES_NODOCTEST'] = '1' + +# pep8.py uses sys.argv to find setup.cfg +sys.argv = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)] + +# git usurbs your bin path for hooks and will always run system python +if 'VIRTUAL_ENV' in os.environ: + site_packages = glob.glob( + '%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0] + sys.path.insert(0, site_packages) + + +def main(): + from flake8.main import DEFAULT_CONFIG + from flake8.engine import get_style_guide + from flake8.hooks import run + + gitcmd = "git diff-index --cached --name-only HEAD" + + _, files_modified, _ = run(gitcmd) + + # remove non-py files and files which no longer exist + files_modified = filter( + lambda x: x.endswith('.py') and os.path.exists(x), + files_modified) + + flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG) + report = flake8_style.check_files(files_modified) + + return report.total_errors + +if __name__ == '__main__': + sys.exit(main()) diff --git a/hooks/pre-commit.verify-docs b/hooks/pre-commit.verify-docs new file mode 120000 index 0000000..43fcf08 --- /dev/null +++ b/hooks/pre-commit.verify-docs @@ -0,0 +1 @@ +../docs/_sentryext/verify-docs.py
\ No newline at end of file |