Skip to content

Commit

Permalink
Fixing bug where Pattern wasnt getting passed correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaivpp committed Jun 30, 2021
1 parent 3952235 commit 49e4229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions commit_msg_regex_hook/commit_msg_regex_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ def process_file(path: str) -> str:
return msg


def process_pattern(pattern: str) -> Pattern:
def process_pattern(pattern_str: str) -> Pattern:
"""Verify regex pattern and return the pattern object
"""
try:
pattern = re.compile(pattern)
print(f"Incoming Pattern: {pattern_str}")
pattern = re.compile(pattern_str)
except Exception as e:
raise argparse.ArgumentTypeError(
f"'{pattern}' is not a valid regex pattern\n {e}"
f"'{pattern_str}' is not a valid regex pattern\n {e}"
)

return pattern
Expand All @@ -102,11 +103,11 @@ def check():
return check


def message_pattern_match(msg: str, pattern: str) -> Result:
def message_pattern_match(msg: str, pattern: Pattern) -> Result:
"""Verify the commit message matches the pattern
"""
def check():
if not re.match(pattern, msg):
if not pattern.match(msg):
# Fail the commit message
return Result(f"Commit Message does not match pattern\n\t{pattern}\n\t{msg}", FAIL)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = commit-msg-regex-hook
version = v0.0.6
version = v0.0.7
author = David Tippett
description = Checks if commit message matches supplied regex
long_description = file: README.md
Expand Down

0 comments on commit 49e4229

Please sign in to comment.