Skip to content

Commit 8fc70e0

Browse files
committed
Small updates to readability.
1 parent 4330523 commit 8fc70e0

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

commit_msg_regex_hook/commit_msg_regex_hook.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def main():
6262

6363
def 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

0 commit comments

Comments
 (0)