diff options
| author | Jeff Carr <[email protected]> | 2025-01-05 19:45:29 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-05 19:45:29 -0600 |
| commit | 6cbd7e67af54a9854740aeab288bc9e447569337 (patch) | |
| tree | 2775ad43933b2d36efd45f55f0d402ddc03b7b4d /repoNew.go | |
| parent | 7e5db53e9d3868472e98b531799e56836298be14 (diff) | |
attempt custom branch namesv0.0.43
Diffstat (limited to 'repoNew.go')
| -rw-r--r-- | repoNew.go | 91 |
1 files changed, 62 insertions, 29 deletions
@@ -43,43 +43,76 @@ func (f *Forge) ValidGoVersion(ver string) (bool, error) { return true, nil } +// figure out what the name of the git master branch is +// also check the forge config +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) + repo.SetMasterBranchName(bname) + return + } + + // try to guess what the 'master' branch is + if repo.IsBranch("master") { + repo.SetMasterBranchName("master") + return + } + + if repo.IsBranch("main") { + repo.SetMasterBranchName("main") + return + } + + // TODO: figure out the name from git + repo.SetMasterBranchName("master") + if repo.CheckoutMaster() { + } else { + cmd := []string{"git", "branch", "master"} + repo.Run(cmd) + } +} + +// figure out what the name of the git devel branch is +// also check the forge config +func (f *Forge) findDevelBranch(repo *gitpb.Repo) { + // check the forge config first + if bname := f.Config.FindDevelBranch(repo.GetGoPath()); bname != "" { + repo.SetDevelBranchName(bname) + if repo.CheckoutDevel() { + } else { + cmd := []string{"git", "branch", bname} + repo.Run(cmd) + } + return + } + + if repo.IsBranch("devel") { + repo.SetDevelBranchName("devel") + return + } + + // TODO: figure out the name from git + repo.SetDevelBranchName("devel") + if repo.CheckoutDevel() { + } else { + cmd := []string{"git", "branch", "devel"} + repo.Run(cmd) + } +} + // this is still in flux func (f *Forge) VerifyBranchNames(repo *gitpb.Repo) { // log.Info("init worked for", repo.GoPath) if repo.GetMasterBranchName() == "" { - // try to guess what the 'master' branch is - if repo.IsBranch("guimaster") { - repo.SetMasterBranchName("guimaster") - } else if repo.IsBranch("master") { - repo.SetMasterBranchName("master") - } else if repo.IsBranch("main") { - repo.SetMasterBranchName("main") - } else { - // todo, figure out the name from git - repo.SetMasterBranchName("master") - if repo.CheckoutMaster() { - } else { - cmd := []string{"git", "branch", "master"} - repo.Run(cmd) - } - } + f.findMasterBranch(repo) } if repo.GetDevelBranchName() == "" { - if repo.IsBranch("guidevel") { - repo.SetDevelBranchName("guidevel") - } else if repo.IsBranch("devel") { - repo.SetDevelBranchName("devel") - } else { - // forcing for now. todo: warn users - repo.SetDevelBranchName("devel") - if repo.CheckoutDevel() { - } else { - cmd := []string{"git", "branch", "devel"} - repo.Run(cmd) - } - } + f.findDevelBranch(repo) } if repo.GetUserBranchName() == "" { |
