mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 12:06:53 +00:00
add the code
This commit is contained in:
parent
6c464e2702
commit
3d0466f30b
2 changed files with 25 additions and 1 deletions
24
pre_commit_hooks/no_commit_to_branch.py
Normal file
24
pre_commit_hooks/no_commit_to_branch.py
Normal 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())
|
||||||
2
setup.py
2
setup.py
|
|
@ -6,7 +6,7 @@ setup(
|
||||||
name='pre_commit_hooks',
|
name='pre_commit_hooks',
|
||||||
description='Some out-of-the-box hooks for pre-commit.',
|
description='Some out-of-the-box hooks for pre-commit.',
|
||||||
url='https://github.com/pre-commit/pre-commit-hooks',
|
url='https://github.com/pre-commit/pre-commit-hooks',
|
||||||
version='0.6.0a',
|
version='0.6.0b',
|
||||||
|
|
||||||
author='Anthony Sottile',
|
author='Anthony Sottile',
|
||||||
author_email='asottile@umich.edu',
|
author_email='asottile@umich.edu',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue