summaryrefslogtreecommitdiffstats
path: root/git
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--git/git.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/git/git.go b/git/git.go
index a34d679..3756840 100644
--- a/git/git.go
+++ b/git/git.go
@@ -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")
+}