1
0
Fork 0
forked from forgejo/forgejo

Add wildcard support to REPO_INDEXER_EXTENSIONS

This commit is contained in:
Guillermo Prandi 2019-08-07 01:26:12 -03:00
parent 021014acfe
commit 72a650c8e4
6 changed files with 42 additions and 29 deletions

View file

@ -232,14 +232,16 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e
}
func isIndexable(entry *git.TreeEntry) bool {
if setting.Indexer.FileExtensions != nil {
var ext string
parts := strings.Split(entry.Name(), ".")
cnt := len(parts)
if cnt > 1 {
ext = strings.ToLower(parts[cnt-1])
if setting.Indexer.FilePatterns != nil {
var found bool
name := strings.ToLower(entry.Name())
for _, g := range setting.Indexer.FilePatterns {
if g.Match(name) {
found = true
break
}
}
if setting.Indexer.FileExtensions[ext] != setting.Indexer.IncludeExtensions {
if found != setting.Indexer.IncludePatterns {
return false
}
}