Skip to content

Commit

Permalink
Merge pull request #7 from mx-psi/mx-psi/depth-one
Browse files Browse the repository at this point in the history
Make a shallow clone when cloning a git repository
  • Loading branch information
bzz authored Apr 1, 2021
2 parents ba86d0a + dae94b5 commit 4c9588d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions licensedb/filer/filer.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ type gitFiler struct {
root *object.Tree
}

// FromGitURL returns a Filer that allows accessing all the files in a Git repository given its URL.
// FromGitURL returns a Filer that allows to access all the files in a Git repository's default branch given its URL.
// It keeps a shallow single-branch clone of the repository in memory.
func FromGitURL(url string) (Filer, error) {
repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{URL: url})
repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{URL: url, Depth: 1})
if err != nil {
return nil, errors.Wrapf(err, "could not clone repo from %s", url)
}
Expand Down

0 comments on commit 4c9588d

Please sign in to comment.