forked from toolshed/abra
feat: recipe fetch command
Also may have rooted out another go-git cloning bug 🙄 Closes coop-cloud/organising#365
This commit is contained in:
@ -15,22 +15,32 @@ import (
|
||||
func Clone(dir, url string) error {
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
logrus.Debugf("%s does not exist, attempting to git clone from %s", dir, url)
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{URL: url, Tags: git.AllTags})
|
||||
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
|
||||
SingleBranch: true,
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Debugf("cloning %s default branch failed, attempting from main branch", url)
|
||||
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
ReferenceName: plumbing.ReferenceName("refs/heads/main"),
|
||||
SingleBranch: true,
|
||||
})
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "authentication required") {
|
||||
name := filepath.Base(dir)
|
||||
return fmt.Errorf("unable to clone %s, does %s exist?", name, url)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("%s has been git cloned successfully", dir)
|
||||
} else {
|
||||
logrus.Debugf("%s already exists", dir)
|
||||
|
Reference in New Issue
Block a user