Skip to content

Commit e683cf2

Browse files
authored
Merge pull request #29 from galbaneim-orca/EE-629-error-when-parsing-file-names-with-parentheses-in-codeowners-open-source
EE-629 fix fork parsing ( ) bug
2 parents cac2119 + 008b91f commit e683cf2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func isAlphanumeric(ch rune) bool {
245245
// isPatternChar matches characters that are allowed in patterns
246246
func isPatternChar(ch rune) bool {
247247
switch ch {
248-
case '*', '?', '.', '/', '@', '_', '+', '-', '\\':
248+
case '*', '?', '.', '/', '@', '_', '+', '-', '\\', '(', ')':
249249
return true
250250
}
251251
return isAlphanumeric(ch)

parse_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,38 @@ func TestParseRule(t *testing.T) {
3131
Owners: []Owner{{Value: "org/team", Type: "team"}},
3232
},
3333
},
34+
{
35+
name: "team owners file with parentheses",
36+
rule: "file(1).txt @org/team",
37+
expected: Rule{
38+
pattern: mustBuildPattern(t, "file(1).txt"),
39+
Owners: []Owner{{Value: "org/team", Type: "team"}},
40+
},
41+
},
42+
{
43+
name: "team owners file with one parentheses on the left",
44+
rule: "file(1.txt @user",
45+
expected: Rule{
46+
pattern: mustBuildPattern(t, "file(1.txt"),
47+
Owners: []Owner{{Value: "user", Type: "username"}},
48+
},
49+
},
50+
{
51+
name: "team owners file with one parentheses on the right",
52+
rule: "file1).txt [email protected]",
53+
expected: Rule{
54+
pattern: mustBuildPattern(t, "file1).txt"),
55+
Owners: []Owner{{Value: "[email protected]", Type: "email"}},
56+
},
57+
},
58+
{
59+
name: "team owners file with parentheses in the folder name",
60+
rule: "(folder)/file.txt @org/team",
61+
expected: Rule{
62+
pattern: mustBuildPattern(t, "(folder)/file.txt"),
63+
Owners: []Owner{{Value: "org/team", Type: "team"}},
64+
},
65+
},
3466
{
3567
name: "email owners",
3668
rule: "file.txt [email protected]",

0 commit comments

Comments
 (0)