Skip to content

Commit

Permalink
add missing comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
richardjennings committed Nov 4, 2024
1 parent b564634 commit 51cbf9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func IsIgnored(path string, rules [][]byte) bool {
}
if v[len(v)-1] == '/' {
dirMatch = true
if v[0] != '/' {
v = append([]byte{'/'}, v...)
}
}

// check for suffix match
Expand All @@ -60,7 +63,7 @@ func IsIgnored(path string, rules [][]byte) bool {
}

if dirMatch {
if path[len(path)-1] == '/' {
if bytes.Equal([]byte(path), v) {
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions ignore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestIsIgnored(t *testing.T) {
// match at any level below the .gitignore level.
{Pattern: "/a", Path: "/a", Expect: true},
{Pattern: "a", Path: "/a", Expect: true},
{Pattern: "/a/", Path: "/b/", Expect: false},
{Pattern: "a", Path: "/b/a", Expect: true},
{Pattern: "a", Path: "/c/b/a", Expect: true},
{Pattern: "/a/b", Path: "/a/b", Expect: true},
Expand Down

0 comments on commit 51cbf9c

Please sign in to comment.