Add a filter to RepositoryService.SearchFilesByName
The Go module proxy (!27746 (merged)) and Go packages support (!29642 (closed)) need to query Gitaly for a list of all go.mod
files in a repository. RepositoryService.SearchFilesByName
can be used, but git ls-tree
and thus SearchFilesByName
does not support glob queries, so the entire repository contents must be listed. Since go.mod
files are the only results of interest, most of the results transmitted from Gitaly are discarded. Introducing filtering to SearchFilesByName would reduce unnecessary data transmission.
For a given ref, scan for all files matching a pattern. A possible implementation would be
RepositoryService.SearchFilesByName
(akagit ls-tree --full-tree --name-status -r <ref> <path>
) plus filtering the output. Or maybe an additional optional field for SearchFilesByName that will apply a regex or glob to the output. For Go, I would search for**/go.mod
.git ls-tree
allows some patterns, but not in a way that is useful to me.
This issue corresponds to Rails support for gitaly#2818 (closed).