Skip to content

Commit

Permalink
Merge pull request #14 from lumapps/chore/jira/fix_pattern
Browse files Browse the repository at this point in the history
fix(jira): the jira pattern
  • Loading branch information
Anis authored Jan 4, 2023
2 parents 22cdf20 + 1c9fe51 commit cbbb75b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion changelog_generator/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
re_header_pattern = re.compile(
r"^(?P<type>[^\(]+)\((?P<scope>[^\)]+)\): (?P<subject>.+)$"
)
re_jira_pattern = re.compile(r"([A-Z]{2,4}-[0-9]{1,6})")
re_jira_pattern = re.compile(r"\b([A-Z]{2,6}[0-9]{0,6}-[0-9]{1,6})\b")
re_broke_pattern = re.compile(r"^BROKEN:$")
re_revert_header_pattern = re.compile(r"^[R|r]evert:? (?P<summary>.*)$")
re_revert_commit_pattern = re.compile(r"^This reverts commit ([a-f0-9]+)")
Expand Down
23 changes: 23 additions & 0 deletions tests/test_jira_extraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from changelog_generator.commit import Commit


def test_no_reference():
commit = Commit("", "", "a commit without any reference")

assert commit.jiras == []


def test_one_reference():
commit = Commit("", "", "this is a reference ABCD-1")

assert commit.jiras == ["ABCD-1"]


def test_several_reference():
commit = Commit(
"",
"",
"valid references ABCD-1 AB-0001 FOO2-1, and not valid ones A-123 abc-145 ABC_524 ",
)

assert commit.jiras == ["ABCD-1", "AB-0001", "FOO2-1"]

0 comments on commit cbbb75b

Please sign in to comment.