-
Notifications
You must be signed in to change notification settings - Fork 898
Closed
Description
All new GitHub repos are created with a default branch of main, instead of the older master.
If I try to clone such a repo with the SingleBranch option enabled, I see an error like couldn't find remote ref "refs/heads/master".
This code demonstrates the issue (the repo https://github.com/hairyhenderson/hitron_coda.git has a default branch of main):
package main
import (
"fmt"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory"
)
func main() {
fs := memfs.New()
storer := memory.NewStorage()
opts := &git.CloneOptions{
URL: "https://github.com/hairyhenderson/hitron_coda.git",
SingleBranch: true,
}
_, err := git.Clone(storer, fs, opts)
if err != nil {
fmt.Println(err)
}
}$ go run main.go
couldn't find remote ref "refs/heads/master"If I set SingleBranch to false it succeeds, but this isn't desirable for my use-case since I want to minimize what I'm pulling down.
The issue seems rooted in this code, which defaults to the plumbing.Master constant when SingleBranch is true and ReferenceName defaults to HEAD.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels