From 6e2f3ed4d430c845b42865d651f291f945aeecf2 Mon Sep 17 00:00:00 2001 From: Markus Tauchnitz Date: Mon, 4 Nov 2024 18:19:18 +0100 Subject: [PATCH] fix(commit-msg): pattern should be only checked in uncommented text --- giticket/giticket.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/giticket/giticket.py b/giticket/giticket.py index 7b4cde0..beb37b8 100644 --- a/giticket/giticket.py +++ b/giticket/giticket.py @@ -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)