Skip to content

Commit e33f80c

Browse files
authored
Fix #605: drop support of tag prefixes (#608)
1 parent d517cd3 commit e33f80c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

jbi/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ def lookup_action(self, actions: Actions) -> Action:
229229
Find first matching action from bug's whiteboard field.
230230
231231
Tags are strings between brackets and can have prefixes/suffixes
232-
using dashes (eg. ``[project]``, ``[project-moco]``, ``[backlog-project]``).
232+
using dashes (eg. ``[project]``, ``[project-moco]``, ``[project-moco-sprint1]``).
233233
"""
234234
if self.whiteboard:
235235
for tag, action in actions.by_tag.items():
236-
# [tag-word], [word-tag], [tag-], [tag], but not [wordtag]
237-
search_string = r"\[([^\]]*-)*" + tag + r"(-[^\]]*)*\]"
236+
# [tag-word], [tag-], [tag], but not [word-tag] or [tagword]
237+
search_string = r"\[" + tag + r"(-[^\]]*)*\]"
238238
if re.search(search_string, self.whiteboard, flags=re.IGNORECASE):
239239
return action
240240

tests/unit/test_models.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,10 @@ def test_extract_see_also(see_also, expected):
7373
@pytest.mark.parametrize(
7474
"whiteboard",
7575
[
76+
"[DevTest]",
7677
"[DevTest-]",
77-
"[-DevTest-]",
78-
"[-DevTest]",
7978
"[DevTest-test]",
80-
"[test-DevTest]",
81-
"[foo-DevTest-bar]",
82-
"[foo-bar-DevTest-foo-bar]",
79+
"[DevTest-test-foo]",
8380
"[example][DevTest]",
8481
"[DevTest][example]",
8582
"[example][DevTest][example]",
@@ -96,6 +93,11 @@ def test_lookup_action_found(whiteboard, actions_example):
9693
"whiteboard",
9794
[
9895
"DevTest",
96+
"[-DevTest-]",
97+
"[-DevTest]",
98+
"[test-DevTest]",
99+
"[foo-DevTest-bar]",
100+
"[foo-bar-DevTest-foo-bar]",
99101
"foo DevTest",
100102
"DevTest bar",
101103
"foo DevTest bar",

0 commit comments

Comments
 (0)