diff --git a/pre_commit_hooks/no_commit_to_branch.py b/pre_commit_hooks/no_commit_to_branch.py new file mode 100644 index 0000000..01dee5a --- /dev/null +++ b/pre_commit_hooks/no_commit_to_branch.py @@ -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()) diff --git a/setup.py b/setup.py index 1f9fb80..2265df7 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='pre_commit_hooks', description='Some out-of-the-box hooks for pre-commit.', url='https://github.com/pre-commit/pre-commit-hooks', - version='0.6.0a', + version='0.6.0b', author='Anthony Sottile', author_email='asottile@umich.edu',