From b1a0d54bd3e5e62cb1b236c0100bcb63bf45147d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 5 Jan 2025 10:37:30 +0100 Subject: [PATCH] fix: default to main then master --- pkg/git/clone.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/git/clone.go b/pkg/git/clone.go index c295766f..001900c2 100644 --- a/pkg/git/clone.go +++ b/pkg/git/clone.go @@ -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