Skip to content

Commit 0639247

Browse files
guillep2kzeripath
authored andcommitted
Skip non-regular files (e.g. submodules) on repo indexing (#7711)
1 parent 0fabdf0 commit 0639247

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

models/repo_indexer.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,28 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e
231231
return indexerUpdate.AddToFlushingBatch(batch)
232232
}
233233

234+
func isIndexable(entry *git.TreeEntry) bool {
235+
return entry.IsRegular()
236+
}
237+
234238
// parseGitLsTreeOutput parses the output of a `git ls-tree -r --full-name` command
235239
func parseGitLsTreeOutput(stdout []byte) ([]fileUpdate, error) {
236240
entries, err := git.ParseTreeEntries(stdout)
237241
if err != nil {
238242
return nil, err
239243
}
244+
var idxCount = 0
240245
updates := make([]fileUpdate, len(entries))
241-
for i, entry := range entries {
242-
updates[i] = fileUpdate{
243-
Filename: entry.Name(),
244-
BlobSha: entry.ID.String(),
246+
for _, entry := range entries {
247+
if isIndexable(entry) {
248+
updates[idxCount] = fileUpdate{
249+
Filename: entry.Name(),
250+
BlobSha: entry.ID.String(),
251+
}
252+
idxCount++
245253
}
246254
}
247-
return updates, nil
255+
return updates[:idxCount], nil
248256
}
249257

250258
// genesisChanges get changes to add repo to the indexer for the first time

0 commit comments

Comments
 (0)