Skip to content

Commit cbbb75b

Browse files
author
Anis
authored
Merge pull request #14 from lumapps/chore/jira/fix_pattern
fix(jira): the jira pattern
2 parents 22cdf20 + 1c9fe51 commit cbbb75b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

changelog_generator/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
re_header_pattern = re.compile(
55
r"^(?P<type>[^\(]+)\((?P<scope>[^\)]+)\): (?P<subject>.+)$"
66
)
7-
re_jira_pattern = re.compile(r"([A-Z]{2,4}-[0-9]{1,6})")
7+
re_jira_pattern = re.compile(r"\b([A-Z]{2,6}[0-9]{0,6}-[0-9]{1,6})\b")
88
re_broke_pattern = re.compile(r"^BROKEN:$")
99
re_revert_header_pattern = re.compile(r"^[R|r]evert:? (?P<summary>.*)$")
1010
re_revert_commit_pattern = re.compile(r"^This reverts commit ([a-f0-9]+)")

tests/test_jira_extraction.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from changelog_generator.commit import Commit
2+
3+
4+
def test_no_reference():
5+
commit = Commit("", "", "a commit without any reference")
6+
7+
assert commit.jiras == []
8+
9+
10+
def test_one_reference():
11+
commit = Commit("", "", "this is a reference ABCD-1")
12+
13+
assert commit.jiras == ["ABCD-1"]
14+
15+
16+
def test_several_reference():
17+
commit = Commit(
18+
"",
19+
"",
20+
"valid references ABCD-1 AB-0001 FOO2-1, and not valid ones A-123 abc-145 ABC_524 ",
21+
)
22+
23+
assert commit.jiras == ["ABCD-1", "AB-0001", "FOO2-1"]

0 commit comments

Comments
 (0)