Skip to content

Commit f5f7877

Browse files
committed
Fix missing RepoURLs and LineFragments for result subrepositories
RepoURLs for subrepositories are currently filtered out when results are streamed per-repo from shards.
1 parent 085b391 commit f5f7877

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

search/shards.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,33 @@ func sendByRepository(result *zoekt.SearchResult, opts *zoekt.SearchOptions, sen
816816

817817
send := func(repoName string, a, b int, stats zoekt.Stats) {
818818
index.SortFiles(result.Files[a:b])
819+
820+
// Filter RepoURLs and LineFragments to only those of repoName and its subRepositories
821+
repoNames := []string{repoName}
822+
for _, file := range result.Files[a:b] {
823+
repoNames = append(repoNames, file.SubRepositoryName)
824+
}
825+
826+
filteredRepoURLs := make(map[string]string)
827+
filteredLineFragments := make(map[string]string)
828+
for _, name := range repoNames {
829+
if url, ok := result.RepoURLs[name]; ok {
830+
filteredRepoURLs[name] = url
831+
}
832+
if frag, ok := result.LineFragments[name]; ok {
833+
filteredLineFragments[name] = frag
834+
}
835+
}
836+
819837
sender.Send(&zoekt.SearchResult{
820838
Stats: stats,
821839
Progress: zoekt.Progress{
822840
Priority: result.Files[a].RepositoryPriority,
823841
MaxPendingPriority: result.MaxPendingPriority,
824842
},
825843
Files: result.Files[a:b],
826-
RepoURLs: map[string]string{repoName: result.RepoURLs[repoName]},
827-
LineFragments: map[string]string{repoName: result.LineFragments[repoName]},
844+
RepoURLs: filteredRepoURLs,
845+
LineFragments: filteredLineFragments,
828846
})
829847
}
830848

0 commit comments

Comments
 (0)