Skip to content

Commit 49e4229

Browse files
committed
Fixing bug where Pattern wasnt getting passed correctly.
1 parent 3952235 commit 49e4229

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

commit_msg_regex_hook/commit_msg_regex_hook.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ def process_file(path: str) -> str:
7878
return msg
7979

8080

81-
def process_pattern(pattern: str) -> Pattern:
81+
def process_pattern(pattern_str: str) -> Pattern:
8282
"""Verify regex pattern and return the pattern object
8383
"""
8484
try:
85-
pattern = re.compile(pattern)
85+
print(f"Incoming Pattern: {pattern_str}")
86+
pattern = re.compile(pattern_str)
8687
except Exception as e:
8788
raise argparse.ArgumentTypeError(
88-
f"'{pattern}' is not a valid regex pattern\n {e}"
89+
f"'{pattern_str}' is not a valid regex pattern\n {e}"
8990
)
9091

9192
return pattern
@@ -102,11 +103,11 @@ def check():
102103
return check
103104

104105

105-
def message_pattern_match(msg: str, pattern: str) -> Result:
106+
def message_pattern_match(msg: str, pattern: Pattern) -> Result:
106107
"""Verify the commit message matches the pattern
107108
"""
108109
def check():
109-
if not re.match(pattern, msg):
110+
if not pattern.match(msg):
110111
# Fail the commit message
111112
return Result(f"Commit Message does not match pattern\n\t{pattern}\n\t{msg}", FAIL)
112113

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = commit-msg-regex-hook
3-
version = v0.0.6
3+
version = v0.0.7
44
author = David Tippett
55
description = Checks if commit message matches supplied regex
66
long_description = file: README.md

0 commit comments

Comments
 (0)