mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-13 22:24:45 +00:00
Added loaderon-hooks logic
This commit is contained in:
parent
0b70e285e3
commit
0a66e6635d
23 changed files with 612 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
from pre_commit_logic.util.template_methods.checker_template_method import CheckerTemplateMethod
|
||||
from pre_commit_logic.util.git_helpers import get_current_branch_name
|
||||
|
||||
|
||||
class BranchNameChecker(CheckerTemplateMethod):
|
||||
def _add_arguments_to_parser(self):
|
||||
self.parser.add_argument('-r', '--regex', help='Regex that git current branch must match.')
|
||||
|
||||
def _perform_checks(self):
|
||||
regular_expression = self.args.regex
|
||||
pattern = re.compile(regular_expression)
|
||||
current_branch_name = get_current_branch_name()
|
||||
if not pattern.match(current_branch_name):
|
||||
self.inform_check_failure('El nombre de la rama debe ser del estilo {}'.format(regular_expression))
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
return BranchNameChecker(argv).run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue