Alexandre Rodrigues 3 days ago committed by GitHub
commit 6eeb6ecd38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -172,8 +172,8 @@ func (r *Rules) parseRule(rule string) error {
if after, ok := strings.CutPrefix(rule, "/"); ok {
// Require path matches the root path.
rule = after
p.match = func(n string, _ os.FileInfo) bool {
rule = after
ok, err := filepath.Match(rule, n)
if err != nil {
slog.Error("failed to compile", slog.String("rule", rule), slog.Any("error", err))

@ -20,6 +20,7 @@ import (
"bytes"
"os"
"path/filepath"
"sync"
"testing"
"github.com/stretchr/testify/assert"
@ -133,3 +134,18 @@ func parseString(str string) (*Rules, error) {
b := bytes.NewBuffer([]byte(str))
return Parse(b)
}
func TestIgnoreRootPatternConcurrent(t *testing.T) {
rules, err := parseString("/root.txt")
require.NoError(t, err)
var workers sync.WaitGroup
for range 8 {
workers.Go(func() {
for range 100 {
assert.True(t, rules.Ignore("root.txt", nil))
assert.False(t, rules.Ignore("nested/root.txt", nil))
}
})
}
workers.Wait()
}

Loading…
Cancel
Save