Skip to content

Commit

Permalink
fix(commit-msg): pattern should be only checked in uncommented text
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Tauchnitz committed Nov 4, 2024
1 parent d1a1d97 commit cb28c71
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions giticket/giticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
def update_commit_message(filename, regex, mode, format_string):
with io.open(filename, 'r+') as fd:
contents = fd.readlines()
commit_msg = contents[0].rstrip('\r\n')
commit_msg = [line for line in contents if not line.startswith('#')]
# Check if we can grab ticket info from branch name.
branch = get_branch_name()

# Bail if commit message already contains tickets
if any(re.search(regex, content) for content in contents):
if any(re.search(regex, commit_msg_line) for commit_msg_line in commit_msg):
return

tickets = re.findall(regex, branch)
Expand All @@ -33,7 +33,7 @@ def update_commit_message(filename, regex, mode, format_string):

new_commit_msg = format_string.format(
ticket=tickets[0], tickets=', '.join(tickets),
commit_msg=commit_msg
commit_msg="\n".join(commit_msg)
)

contents[0] = six.text_type(new_commit_msg + "\n")
Expand Down

0 comments on commit cb28c71

Please sign in to comment.