File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 11
22- id : commit-msg-regex-hook
3- name : commit-msg-regex-hook
3+ name : Validate commit message with Regex
44 description : Checks if commit message matches the passed in regex
55 entry : commit-msg-regex-hook
66 language : python
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ First you will need to setup [pre-commit](https://pre-commit.com/) using their d
1313 rev: v0.3.1
1414 hooks:
1515 - id: commit-msg-hook
16- args: [--pattern='[A-Z]{3,4}-[0-9]{3,6} \\| [\\w\\s]* \\| .+']
16+ args: [" --pattern='[A-Z]{3,4}-[0-9]{3,6} \\| [\\w\\s]* \\| .+'" ]
1717 stages: [commit-msg]
1818```
1919
Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ def main():
6262
6363def process_file (path : str ) -> str :
6464 """Extract commit message.
65- On failure the commit is aborted.
6665
6766 Args:
6867 path (str): The path of the file with commit message
@@ -78,15 +77,19 @@ def process_file(path: str) -> str:
7877 return msg
7978
8079
81- def process_pattern (pattern_str : str ) -> Pattern :
82- """Verify regex pattern and return the pattern object
80+ def process_pattern (str_pattern : str ) -> Pattern :
81+ """Convert string pattern to regex pattern object.
82+
83+ Args:
84+ pattern_str (str): The path of the file with commit message
85+ Returns:
86+ pattern (Pattern): The compiled regex pattern.
8387 """
8488 try :
85- print (f"Incoming Pattern: { pattern_str } " )
86- pattern = re .compile (pattern_str [1 :- 1 ])
89+ pattern = re .compile (str_pattern [1 :- 1 ])
8790 except Exception as e :
8891 raise argparse .ArgumentTypeError (
89- f"'{ pattern_str } ' is not a valid regex pattern\n { e } "
92+ f"'{ str_pattern } ' is not a valid regex pattern\n { e } "
9093 )
9194
9295 return pattern
You can’t perform that action at this time.
0 commit comments