Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commit-msg): pattern should be only checked in uncommented text #31

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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