diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-13 09:58:40 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-13 09:58:40 +0530 |
commit | eda8b58d9f2e85f1bae92ce3b70f279b89031046 (patch) | |
tree | 8b365320501fbbcac08f7abb9087eaef9c9b2711 /git | |
parent | 551c6637250172c5a2ca05070c011b1d72bb7d02 (diff) | |
download | legit-eda8b58d9f2e85f1bae92ce3b70f279b89031046.tar.gz legit-eda8b58d9f2e85f1bae92ce3b70f279b89031046.tar.bz2 legit-eda8b58d9f2e85f1bae92ce3b70f279b89031046.zip |
git: find main branch from config
Diffstat (limited to '')
-rw-r--r-- | git/git.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -110,3 +110,13 @@ func (g *GitRepo) Branches() ([]*plumbing.Reference, error) { return branches, nil } + +func (g *GitRepo) FindMainBranch(branches []string) (string, error) { + for _, b := range branches { + _, err := g.r.ResolveRevision(plumbing.Revision(b)) + if err == nil { + return b, nil + } + } + return "", fmt.Errorf("unable to find main branch") +} |