finally pull the origin repo name from the right place

This commit is contained in:
Jeff Carr 2025-01-07 22:29:17 -06:00
parent e6e70ccaa5
commit bd3e924e2b
1 changed files with 14 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package forgepb
import (
"fmt"
"os"
"path/filepath"
"strings"
@ -48,12 +49,22 @@ func (f *Forge) ValidGoVersion(ver string) (bool, error) {
func (f *Forge) findMasterBranch(repo *gitpb.Repo) {
// check the forge config first
if bname := f.Config.FindMasterBranch(repo.GetGoPath()); bname != "" {
log.Info("FOUND CONFIG NAME", bname)
log.Info("FOUND CONFIG NAME", bname)
log.Info("FOUND CONFIG NAME", bname)
log.Info("Using master branch name from forge config:", bname)
repo.SetMasterBranchName(bname)
return
}
// todo: fix this after .git parsing is better or libgit2 is being used
headfile := filepath.Join(repo.GetFullPath(), ".git/refs/remotes/origin/HEAD")
if data, err := os.ReadFile(headfile); err == nil {
s := string(data)
if strings.HasPrefix(s, "ref: ") {
fields := strings.Fields(s)
_, bname := filepath.Split(fields[1])
log.Info("Using master branch name from .git/ HEAD:", bname)
repo.SetMasterBranchName(bname)
return
}
}
// try to guess what the 'master' branch is
if repo.IsBranch("master") {