finally pull the origin repo name from the right place
This commit is contained in:
parent
e6e70ccaa5
commit
bd3e924e2b
17
repoNew.go
17
repoNew.go
|
@ -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") {
|
||||
|
|
Loading…
Reference in New Issue