attempt custom branch names
This commit is contained in:
parent
7e5db53e9d
commit
6cbd7e67af
|
@ -260,3 +260,65 @@ func (fc *ForgeConfigs) FindUserBranch(thing string) string {
|
|||
|
||||
return match.UserBranchName
|
||||
}
|
||||
|
||||
// allows custom devel branch names in the forge config
|
||||
func (fc *ForgeConfigs) FindDevelBranch(thing string) string {
|
||||
var match *ForgeConfig
|
||||
|
||||
all := fc.SortByGoPath() // get the list of repos
|
||||
for all.Scan() {
|
||||
r := all.Next()
|
||||
if r.GoPath == thing {
|
||||
if r.DevelBranchName != "" {
|
||||
return r.DevelBranchName
|
||||
}
|
||||
}
|
||||
base := filepath.Base(r.GoPath)
|
||||
if base == thing {
|
||||
if r.DevelBranchName != "" {
|
||||
return r.DevelBranchName
|
||||
}
|
||||
}
|
||||
if r.Directory {
|
||||
if strings.HasPrefix(thing, r.GoPath) {
|
||||
match = r
|
||||
}
|
||||
}
|
||||
}
|
||||
if match == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return match.DevelBranchName
|
||||
}
|
||||
|
||||
// allows custom devel branch names in the forge config
|
||||
func (fc *ForgeConfigs) FindMasterBranch(thing string) string {
|
||||
var match *ForgeConfig
|
||||
|
||||
all := fc.SortByGoPath() // get the list of repos
|
||||
for all.Scan() {
|
||||
r := all.Next()
|
||||
if r.GoPath == thing {
|
||||
if r.MasterBranchName != "" {
|
||||
return r.MasterBranchName
|
||||
}
|
||||
}
|
||||
base := filepath.Base(r.GoPath)
|
||||
if base == thing {
|
||||
if r.MasterBranchName != "" {
|
||||
return r.MasterBranchName
|
||||
}
|
||||
}
|
||||
if r.Directory {
|
||||
if strings.HasPrefix(thing, r.GoPath) {
|
||||
match = r
|
||||
}
|
||||
}
|
||||
}
|
||||
if match == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return match.MasterBranchName
|
||||
}
|
||||
|
|
91
repoNew.go
91
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() == "" {
|
||||
|
|
Loading…
Reference in New Issue