mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-07 04:26:52 +00:00
Merge 232394b589 into 414cfa7b23
This commit is contained in:
commit
fefc7c417a
3 changed files with 31 additions and 0 deletions
|
|
@ -147,3 +147,9 @@
|
||||||
entry: trailing-whitespace-fixer
|
entry: trailing-whitespace-fixer
|
||||||
language: python
|
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)$
|
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
|
||||||
|
|
|
||||||
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())
|
||||||
1
setup.py
1
setup.py
|
|
@ -55,6 +55,7 @@ setup(
|
||||||
'pretty-format-json = pre_commit_hooks.pretty_format_json:pretty_format_json',
|
'pretty-format-json = pre_commit_hooks.pretty_format_json:pretty_format_json',
|
||||||
'requirements-txt-fixer = pre_commit_hooks.requirements_txt_fixer:fix_requirements_txt',
|
'requirements-txt-fixer = pre_commit_hooks.requirements_txt_fixer:fix_requirements_txt',
|
||||||
'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:fix_trailing_whitespace',
|
'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:fix_trailing_whitespace',
|
||||||
|
'no-commit-to-branch = pre_commit_hooks.no_commit_to_branch:main',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue