Skip to content

Implement a new Gitaly call that locates files across a set of refs

The Go module proxy (!27746 (merged)) needs to locate go.mod at some known path for all valid tags*. Go packages support (!29642 (closed)) needs to locate go.mod at all paths for all valid tags*. Currently this causes N+1 Gitaly calls. Other package types that use Git to define resources and versions, such as Puppet, may benefit from this work.

I propose an interface that accepts a query path and a regex path filter (as in SearchFilesByPath, gitaly#2818 (closed)) and either a list of refs or a regex ref filter, and returns (OID, ref, path) records. In effect, it will iterate over the set of refs, run git ls-tree --full-tree -r <ref> for each, filter the resulting records by path, and return (<oid>, <ref>, <path>).

Proof of Concept - not built for performance.

*A valid Go tag is one that is prefixed with v and conforms to semantic versioning: vX.Y.Z[-<prerelease>][+<build>].

#218083 (comment 347686649):

Get a blob at a path for all refs matching a pattern, or alternatively for a specific set of refs. For Go, I would use this to get all <path/>go.mod files for either all tags matching v* or for a specific set of tags. Either would work, though the latter would allow me to skip tags that are known valid versions.

Edited by Ethan Reesor