Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 42bacef

Browse files
author
Christian Riedel
committed
fix check for empty commit msg; exclude comment lines
1 parent 0e1121f commit 42bacef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/commit_msg_jira_hook/check_jira_tag.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str)
7979
c_msg = cm_file.read()
8080

8181
#: Abort with empty commit-msg
82-
if c_msg == "":
82+
c_msg_lines = [l for l in c_msg.split("\n") if not l.startswith("#") and l != ""]
83+
84+
if len(c_msg_lines) == 0:
8385
click.echo("Commit message is empty.")
8486
ctx.abort()
8587

88+
c_msg_cleaned = "\n".join(c_msg_lines)
89+
8690
#: Extract tag from commit msg
87-
extract = re.search(r"(" + jira_tag.upper() + r")-?([0-9]+)?", c_msg)
91+
extract = re.search(r"(" + jira_tag.upper() + r")-?([0-9]+)?", c_msg_cleaned)
8892

8993
#: Check if tag is in commit msg
9094
if extract is None:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /