Skip to content
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
6 changes: 5 additions & 1 deletion pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,11 @@ func matchKey(rules []rule, key string) bool {
logger.Fatalf("match %s with %s: %v", rule.pattern, suffix, err)
}
if ok {
return rule.include
if rule.include {
break // try next level
} else {
return false
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func TestSuffixForPath(t *testing.T) {
}
for _, tt := range tests {
if got := suffixForPattern(tt.key, tt.pattern); !reflect.DeepEqual(got, tt.want) {
t.Errorf("slidingWindowForPath() = %v, want %v", got, tt.want)
t.Errorf("suffixForPattern() = %v, want %v", got, tt.want)
}
}
}
Expand Down Expand Up @@ -562,10 +562,11 @@ func TestMatchObjects(t *testing.T) {
{rules: []rule{{pattern: "a.go", include: true}, {pattern: "pkg", include: false}}, key: "a/pkg/c/a.go", want: false},
{rules: []rule{{pattern: "a", include: false}, {pattern: "pkg", include: true}}, key: "a/pkg/c/a.go", want: false},
{rules: []rule{{pattern: "a.go", include: true}, {pattern: "pkg", include: false}}, key: "", want: true},
{rules: []rule{{pattern: "a", include: true}, {pattern: "b/", include: false}, {pattern: "c", include: true}}, key: "a/b/c", want: false},
}
for _, tt := range tests {
if got := matchKey(tt.rules, tt.key); got != tt.want {
t.Errorf("includeObject() = %v, want %v", got, tt.want)
t.Errorf("matchKey() = %v, want %v", got, tt.want)
}
}
}