Skip to content

Commit 106faf3

Browse files
committed
Simplify isIndexable() for better clarity
1 parent 7450aee commit 106faf3

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

models/repo_indexer.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,19 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e
232232
}
233233

234234
func isIndexable(entry *git.TreeEntry) bool {
235-
if setting.Indexer.FilePatterns != nil {
236-
var found bool
237-
name := strings.ToLower(entry.Name())
238-
for _, g := range setting.Indexer.FilePatterns {
239-
if g.Match(name) {
240-
found = true
241-
break
242-
}
243-
}
244-
if found != setting.Indexer.IncludePatterns {
245-
return false
235+
if !entry.IsRegular() && !entry.IsExecutable() {
236+
return false
237+
}
238+
if setting.Indexer.FilePatterns == nil {
239+
return true
240+
}
241+
name := strings.ToLower(entry.Name())
242+
for _, g := range setting.Indexer.FilePatterns {
243+
if g.Match(name) {
244+
return setting.Indexer.IncludePatterns
246245
}
247246
}
248-
return entry.IsRegular() || entry.IsExecutable()
247+
return !setting.Indexer.IncludePatterns
249248
}
250249

251250
// parseGitLsTreeOutput parses the output of a `git ls-tree -r --full-name` command

0 commit comments

Comments
 (0)