This commit is contained in:
Evan Felix 2017-03-16 07:15:31 +00:00 committed by GitHub
commit fefc7c417a
3 changed files with 31 additions and 0 deletions

View file

@ -147,3 +147,9 @@
entry: trailing-whitespace-fixer
language: python
files: \.(asciidoc|adoc|coffee|cpp|css|c|ejs|erb|groovy|h|haml|hh|hpp|hxx|html|in|j2|jade|json|js|less|markdown|md|ml|mli|pp|py|rb|rs|R|scala|scss|sh|slim|tex|tmpl|ts|txt|yaml|yml)$
- id: no-commit-to-branch
name: Dont commit to branch
entry: no-commit-to-branch
language: python
files: .*
always_run: true

View file

@ -0,0 +1,24 @@
from __future__ import print_function
import argparse
import sys
import util
def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('-b', default='master', help='branch to disallow commits to')
parser.add_argument('filenames', nargs='*', help='filenames to check.')
args = parser.parse_args(argv)
retval = -1
branch = util.cmd_output('git', 'symbolic-ref', 'HEAD')
chunks = branch.split('/')
if chunks[2] == args.b:
retval = 0
return retval
if __name__ == '__main__':
sys.exit(main())

View file

@ -55,6 +55,7 @@ setup(
'pretty-format-json = pre_commit_hooks.pretty_format_json:pretty_format_json',
'requirements-txt-fixer = pre_commit_hooks.requirements_txt_fixer:fix_requirements_txt',
'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:fix_trailing_whitespace',
'no-commit-to-branch = pre_commit_hooks.no_commit_to_branch:main',
],
},
)