0

My golang application needs to list all file and folder paths in a subfolder of a git repo (a search path). I only care about the HEAD commit. I'm using the go-git library to clone the repo and iterate over the objects in the HEAD tree, listing their name.

repo, _ = git.Clone(memory.NewStorage(), nil, git.CloneOptions{URL: repoUrl, Depth: 1})
// Get commit object at HEAD
// get tree of commit object
// iterate into tree and append file names if file is within my search path

This works but the clone operation is very slow as the repo gets large and probably gives me a ton of stuff I don't need (I'm only interested in a subset of the repo tree). I noticed that the git clone docs have a --filter option that could serve my purposes. Is this option available via the go-git library? I don't see anything in the CloneOptions object

BeetleJuice
  • 39,516
  • 19
  • 105
  • 165

0 Answers0