mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
code cleanup based off asottile comments
This commit is contained in:
parent
44c6676070
commit
7c6b842a92
3 changed files with 13 additions and 14 deletions
|
|
@ -7,26 +7,19 @@ from pre_commit_hooks.util import cmd_output
|
|||
|
||||
|
||||
def is_on_branch(protected):
|
||||
retval = False
|
||||
branch = cmd_output('git', 'symbolic-ref', 'HEAD')
|
||||
chunks = branch.strip().split('/')
|
||||
if chunks[2] == protected:
|
||||
retval = True
|
||||
return retval
|
||||
return chunks[2] == protected
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
def main(argv=[]):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'-b', default='master', help='branch to disallow commits to')
|
||||
parser.add_argument('filenames', nargs='*', help='filenames to check.')
|
||||
'-b', '--branch', default='master', help='branch to disallow commits to')
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if is_on_branch(args.b):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
return int(is_on_branch(args.branch))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue