Skip to content

Commit

Permalink
Moved regex and commit message outputs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaivpp committed Mar 31, 2022
1 parent 320f38c commit b59b521
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions commit_msg_regex_hook/commit_msg_regex_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
the provided regex.
"""

from distutils.log import debug
import sys
import argparse
import re
Expand All @@ -29,8 +30,9 @@
class Result():
"""Class for denoting pass/fail and why for test
"""
def __init__(self, message, result):
def __init__(self, message, result, debug_data=None):
self.message = message
self.debug_data = debug_data
self.result = result

def is_passing(self):
Expand Down Expand Up @@ -93,6 +95,7 @@ def run_checks(checks: list):

if not result.is_passing():
logger.error(f"Check Failed:\n {result.message}")
logger.debug(result.debug_data)
sys.exit(1)

logger.debug(result.message)
Expand Down Expand Up @@ -156,9 +159,9 @@ def check():

if not pattern.search(message):
# Fail the commit message
return Result(f"""{failure_message}\n\t
Pattern: {pattern}\n\t
Message: {message}""", FAIL)
return Result(f"{failure_message}\n",
FAIL,
f"\tPattern: {pattern}\n\tMessage: {message}")

return Result("The commit message matches the regex", PASS)
return check
Expand Down

0 comments on commit b59b521

Please sign in to comment.