Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pattern not ending in slash not matching directory #36

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codeowners.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func getPattern(line string) (*regexp.Regexp, error) {
case strings.HasSuffix(line, "/([^/]*)"):
expr = line + "$"
default:
expr = line + "($|/.+$)"
expr = line + "($|/.*$)"
}

if strings.HasPrefix(expr, "/") {
Expand Down
10 changes: 10 additions & 0 deletions codeowners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ docs/** @org/docteam @joe`
# subdirectories.
/build/logs/ @doctocat

# In this example, @fooowner owns any files in the /cells/foo
# directory at the root of the repository and any of its
# subdirectories and files.
/cells/foo @fooowner

# The 'docs/*' pattern will match files like
# 'docs/getting-started.md' but not further nested files like
# 'docs/build-app/troubleshooting.md'.
Expand Down Expand Up @@ -234,6 +239,11 @@ func TestFullParseCodeowners(t *testing.T) {
{"/docs/foo.js", []string{"@doctocat"}},
{"/space/test space/doc1.txt", []string{"@spaceowner"}},
{"/terraform/kubernetes", []string{"@infra"}},

{"/cells/foo", []string{"@fooowner"}},
{"/cells/foo/", []string{"@fooowner"}},
{"/cells/foo/bar", []string{"@fooowner"}},
{"/cells/foo/bar/quux", []string{"@fooowner"}},
}

for _, d := range data {
Expand Down