all repos — elgit @ eda8b58d9f2e85f1bae92ce3b70f279b89031046

fork of legit: web frontend for git, written in go

git: find main branch from config

commit

eda8b58d9f2e85f1bae92ce3b70f279b89031046

parent

551c6637250172c5a2ca05070c011b1d72bb7d02

1 file changed, 10 insertions(+), 0 deletions(-)

changed files
M git/git.gogit/git.go
@@ -110,3 +110,13 @@ })
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") +}