From 776a8414d4e865201acfe3b6b43fc8c54c01c96e Mon Sep 17 00:00:00 2001 From: stevensting Date: Thu, 26 Dec 2024 18:08:36 +0100 Subject: [PATCH] cloned repos shall contain all branches --- pkg/git/clone.go | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/pkg/git/clone.go b/pkg/git/clone.go index c295766f..7b58a086 100644 --- a/pkg/git/clone.go +++ b/pkg/git/clone.go @@ -8,7 +8,6 @@ import ( "coopcloud.tech/abra/pkg/log" "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" ) // Clone runs a git clone which accounts for different default branches. @@ -17,28 +16,19 @@ func Clone(dir, url string) error { log.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, - ReferenceName: plumbing.ReferenceName("refs/heads/master"), - SingleBranch: true, + URL: url, + Tags: git.AllTags, + // To be able to pull recipe from any branch + SingleBranch: false, }) + if err != nil { - log.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 + 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 } log.Debugf("%s has been git cloned successfully", dir)