summaryrefslogtreecommitdiff
path: root/repoNew.go
diff options
context:
space:
mode:
Diffstat (limited to 'repoNew.go')
-rw-r--r--repoNew.go91
1 files changed, 62 insertions, 29 deletions
diff --git a/repoNew.go b/repoNew.go
index 3630688..a152dc1 100644
--- a/repoNew.go
+++ b/repoNew.go
@@ -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() == "" {