fluxcd / pkg

Toolkit common packages

Home Page:https://pkg.go.dev/github.com/fluxcd/pkg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize cloning Git repositories for the refname checkout strategy

aryan9600 opened this issue · comments

At the moment, cloneRefname() does a git ls-remote and uses the output to figure out the commit hash related to the provided refname. It then simply calls cloneCommit() with the obtained commit hash. While this works and is straightforward, it has the drawback of performing a full clone and not a shallow clone, which can be be a considerable performance hurdle. To avoid this, we should figure out if the provided refname points to a branch/tag and then perform a shallow clone like we do in cloneBranch() and cloneTag()