Skip to content

Commit 8be64fc

Browse files
authored
Fix #552: do not match tags if not surrounded by dashes (#555)
1 parent 9d5c5dd commit 8be64fc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

jbi/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ def lookup_action(self, actions: Actions) -> Action:
272272
"""Find first matching action from bug's whiteboard list"""
273273
if self.whiteboard:
274274
for tag, action in actions.by_tag.items():
275-
search_string = r"\[[^\]]*" + tag + r"[^\]]*\]"
275+
# [tag-word], [word-tag], [tag-], [tag], but not [wordtag]
276+
search_string = r"\[([^\]]*-)*" + tag + r"(-[^\]]*)*\]"
276277
if re.search(search_string, self.whiteboard, flags=re.IGNORECASE):
277278
return action
278279

tests/unit/test_bugzilla.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ def test_extract_see_also(see_also, expected):
3131
@pytest.mark.parametrize(
3232
"whiteboard",
3333
[
34+
"[DevTest-]",
35+
"[-DevTest-]",
36+
"[-DevTest]",
37+
"[DevTest-test]",
38+
"[test-DevTest]",
39+
"[foo-DevTest-bar]",
40+
"[foo-bar-DevTest-foo-bar]",
3441
"[example][DevTest]",
35-
"[example][DevTest-test]",
36-
"[example][test-DevTest]",
37-
"[example][foo-DevTest-bar]",
42+
"[DevTest][example]",
43+
"[example][DevTest][example]",
3844
],
3945
)
4046
def test_lookup_action_found(whiteboard, actions_example):
@@ -48,6 +54,11 @@ def test_lookup_action_found(whiteboard, actions_example):
4854
"whiteboard",
4955
[
5056
"example DevTest",
57+
"[fooDevTest]",
58+
"[DevTestbar]",
59+
"[fooDevTestbar]",
60+
"[fooDevTest-bar]",
61+
"[foo-DevTestbar]",
5162
"[foo] devtest [bar]",
5263
],
5364
)

0 commit comments

Comments
 (0)