Added loaderon-hooks logic

This commit is contained in:
Alvaro Andrés Rodríguez Scelza 2019-06-02 02:10:25 -03:00
parent 0b70e285e3
commit 0a66e6635d
23 changed files with 612 additions and 0 deletions

View file

@ -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())