From dfe70d241724779ef7300a8876226291eba63c39 Mon Sep 17 00:00:00 2001 From: Steve Richert Date: Tue, 14 Jul 2026 13:34:52 -0400 Subject: [PATCH] Allow colons in CODEOWNERS patterns Treat colons as literal pattern characters and cover parsing and matching with a real-world rule. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 47810418-339a-4a4b-ad02-d060059420ce --- parse.go | 2 +- parse_test.go | 8 ++++++++ testdata/patterns.json | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/parse.go b/parse.go index 60a7ac6..dda588c 100644 --- a/parse.go +++ b/parse.go @@ -257,7 +257,7 @@ func isAlphanumeric(ch rune) bool { // isPatternChar matches characters that are allowed in patterns func isPatternChar(ch rune) bool { switch ch { - case '*', '?', '.', '/', '@', '_', '+', '-', '\\', '(', ')', '|', '{', '}': + case '*', '?', '.', '/', '@', '_', '+', '-', ':', '\\', '(', ')', '|', '{', '}': return true } return isAlphanumeric(ch) diff --git a/parse_test.go b/parse_test.go index 24ec8c8..d6ae66c 100644 --- a/parse_test.go +++ b/parse_test.go @@ -171,6 +171,14 @@ func TestParseRule(t *testing.T) { Owners: []Owner{{Value: "user", Type: "username"}}, }, }, + { + name: "pattern with colon", + rule: "services/foo:bar/**/* @org/team", + expected: Rule{ + pattern: mustBuildPattern(t, "services/foo:bar/**/*"), + Owners: []Owner{{Value: "org/team", Type: "team"}}, + }, + }, { name: "pattern with space", rule: "foo\\ bar @user", diff --git a/testdata/patterns.json b/testdata/patterns.json index fcf4bac..13846b1 100644 --- a/testdata/patterns.json +++ b/testdata/patterns.json @@ -305,5 +305,13 @@ "foo/qux/bar/baz": true, "foo/qux/bar/qux": false } + }, + { + "name": "pattern with colon", + "pattern": "services/foo:bar/**/*", + "paths": { + "services/foo:bar/baz.json": true, + "services/foo-bar/baz.json": false + } } ] \ No newline at end of file