mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Merge 232394b589 into 414cfa7b23
This commit is contained in:
commit
fefc7c417a
3 changed files with 31 additions and 0 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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue