fix: default to main then master
This commit is contained in:
parent
3869d6bce9
commit
b1a0d54bd3
@ -14,21 +14,22 @@ import (
|
||||
// Clone runs a git clone which accounts for different default branches.
|
||||
func Clone(dir, url string) error {
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
log.Debugf("%s does not exist, attempting to git clone from %s", dir, url)
|
||||
log.Debugf("%s does not exist, attempting git clone of %s", dir, url)
|
||||
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/main"),
|
||||
SingleBranch: true,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Debugf("cloning %s default branch failed, attempting from main branch", url)
|
||||
log.Debug("git clone: main branch failed, attempting master branch")
|
||||
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/main"),
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
|
||||
SingleBranch: true,
|
||||
})
|
||||
if err != nil {
|
||||
@ -41,9 +42,9 @@ func Clone(dir, url string) error {
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("%s has been git cloned successfully", dir)
|
||||
log.Debugf("git clone: %s cloned successfully", dir)
|
||||
} else {
|
||||
log.Debugf("%s already exists", dir)
|
||||
log.Debugf("git clone: %s already exists", dir)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user