diff options
| author | Jeff Carr <[email protected]> | 2025-01-07 22:29:17 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-07 22:29:17 -0600 |
| commit | bd3e924e2b22bceb8db0c7d85c35bc676501ef33 (patch) | |
| tree | 6bd4159ed091fee8a593dfe592b105aee9ffe31b /repoNew.go | |
| parent | e6e70ccaa50a73e571e3251010e06847ad232829 (diff) | |
finally pull the origin repo name from the right place
Diffstat (limited to 'repoNew.go')
| -rw-r--r-- | repoNew.go | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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") { |
