-
Notifications
You must be signed in to change notification settings - Fork 811
Description
Hey y'all ✌️🤠!
Repositories are shifting over to using main
as their base branch.
Today go-git
does not work as expected when cloning a repo with main = head and the following options:
&git.CloneOptions{
URL: url,
Depth: 1,
SingleBranch: true,
ReferenceName: plumbing.HEAD,
}
I kind of dug around and noticed that go-git
hardcodes to plumbing.Master.Short()
here:
Lines 905 to 908 in 4ec1753
case o.SingleBranch && o.ReferenceName == plumbing.HEAD: | |
return []config.RefSpec{ | |
config.RefSpec(fmt.Sprintf(refspecSingleBranchHEAD, o.RemoteName)), | |
config.RefSpec(fmt.Sprintf(refspecSingleBranch, plumbing.Master.Short(), o.RemoteName)), |
This is the git command equivalent:
git clone --single-branch --depth=1 {REPO_URL_WITH_MAIN_BRANCH_AS_BASE}
The expected behavior is that it clones the repository with HEAD
pointing to main
. go-git
returns an error stating couldn't find remote ref "refs/heads/master"
.
Is this something that y'all are aware of or on y'all's road map?
I am more than happy to help contribute a fix!
Just would need some guidance & more time to figure out how config.RefSpec
works and why it's hardcoded to plumbing.Master.Short()
in the switch statement above.