Skip to content

Commit 753774b

Browse files
authored
Repro test for CODEOWNERS leading slashes in pattern & path (#102905)
Adds a test to codify the matching behavior for CODEOWNERS rules when leading slashes are involved between the rule pattern & stack trace path. https://sentry.slack.com/archives/C04KZQBNQ2U/p1762380421731289
1 parent 6bd61b7 commit 753774b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/sentry/issues/ownership/test_grammar.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,3 +1130,58 @@ def test_convert_schema_to_rules_text() -> None:
11301130
)
11311131
== "path:*.js #frontend m@robenolt.com\nurl:http://google.com/* #backend\npath:src/sentry/* david@sentry.io\ntags.foo:bar tagperson@sentry.io\ntags.foo:bar baz tagperson@sentry.io\nmodule:foo.bar #workflow\nmodule:foo bar meow@sentry.io\n"
11321132
)
1133+
1134+
1135+
@pytest.mark.parametrize(
1136+
"pattern, path_details, expected",
1137+
[
1138+
# Pattern WITHOUT leading slash
1139+
# Path WITH leading slash
1140+
# Does not match
1141+
(
1142+
"libs/web/views/index/**",
1143+
[
1144+
{"filename": "/libs/web/views/index/src/widget-table.component.tsx"},
1145+
{"abs_path": "/libs/web/views/index/src/widget-table.component.tsx"},
1146+
],
1147+
False,
1148+
),
1149+
# Pattern WITH leading slash
1150+
# Path WITH leading slash
1151+
# Matches
1152+
(
1153+
"/libs/web/views/index/**",
1154+
[
1155+
{"filename": "/libs/web/views/index/src/widget-table.component.tsx"},
1156+
{"abs_path": "/libs/web/views/index/src/widget-table.component.tsx"},
1157+
],
1158+
True,
1159+
),
1160+
# Pattern WITHOUT leading slash
1161+
# Path WITHOUT leading slash
1162+
# Matches
1163+
(
1164+
"libs/web/views/index/**",
1165+
[
1166+
{"filename": "libs/web/views/index/src/widget-table.component.tsx"},
1167+
{"abs_path": "libs/web/views/index/src/widget-table.component.tsx"},
1168+
],
1169+
True,
1170+
),
1171+
# Pattern WITH leading slash
1172+
# Path WITHOUT leading slash
1173+
# Matches
1174+
(
1175+
"/libs/web/views/index/**",
1176+
[
1177+
{"filename": "libs/web/views/index/home.tsx"},
1178+
{"abs_path": "libs/web/views/index/home.tsx"},
1179+
],
1180+
True,
1181+
),
1182+
],
1183+
)
1184+
def test_codeowners_leading_slash_matching(
1185+
pattern: str, path_details: Sequence[Mapping[str, str]], expected: bool
1186+
) -> None:
1187+
_assert_matcher(Matcher("codeowners", pattern), path_details, expected)

0 commit comments

Comments
 (0)