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
|
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
|
||||||
|
}
|
||||||
|
|
65
repoNew.go
65
repoNew.go
|
@ -43,43 +43,76 @@ func (f *Forge) ValidGoVersion(ver string) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is still in flux
|
// figure out what the name of the git master branch is
|
||||||
func (f *Forge) VerifyBranchNames(repo *gitpb.Repo) {
|
// also check the forge config
|
||||||
// log.Info("init worked for", repo.GoPath)
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if repo.GetMasterBranchName() == "" {
|
|
||||||
// try to guess what the 'master' branch is
|
// try to guess what the 'master' branch is
|
||||||
if repo.IsBranch("guimaster") {
|
if repo.IsBranch("master") {
|
||||||
repo.SetMasterBranchName("guimaster")
|
|
||||||
} else if repo.IsBranch("master") {
|
|
||||||
repo.SetMasterBranchName("master")
|
repo.SetMasterBranchName("master")
|
||||||
} else if repo.IsBranch("main") {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if repo.IsBranch("main") {
|
||||||
repo.SetMasterBranchName("main")
|
repo.SetMasterBranchName("main")
|
||||||
} else {
|
return
|
||||||
// todo, figure out the name from git
|
}
|
||||||
|
|
||||||
|
// TODO: figure out the name from git
|
||||||
repo.SetMasterBranchName("master")
|
repo.SetMasterBranchName("master")
|
||||||
if repo.CheckoutMaster() {
|
if repo.CheckoutMaster() {
|
||||||
} else {
|
} else {
|
||||||
cmd := []string{"git", "branch", "master"}
|
cmd := []string{"git", "branch", "master"}
|
||||||
repo.Run(cmd)
|
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.GetDevelBranchName() == "" {
|
if repo.IsBranch("devel") {
|
||||||
if repo.IsBranch("guidevel") {
|
|
||||||
repo.SetDevelBranchName("guidevel")
|
|
||||||
} else if repo.IsBranch("devel") {
|
|
||||||
repo.SetDevelBranchName("devel")
|
repo.SetDevelBranchName("devel")
|
||||||
} else {
|
return
|
||||||
// forcing for now. todo: warn users
|
}
|
||||||
|
|
||||||
|
// TODO: figure out the name from git
|
||||||
repo.SetDevelBranchName("devel")
|
repo.SetDevelBranchName("devel")
|
||||||
if repo.CheckoutDevel() {
|
if repo.CheckoutDevel() {
|
||||||
} else {
|
} else {
|
||||||
cmd := []string{"git", "branch", "devel"}
|
cmd := []string{"git", "branch", "devel"}
|
||||||
repo.Run(cmd)
|
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() == "" {
|
||||||
|
f.findMasterBranch(repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repo.GetDevelBranchName() == "" {
|
||||||
|
f.findDevelBranch(repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo.GetUserBranchName() == "" {
|
if repo.GetUserBranchName() == "" {
|
||||||
|
|
Loading…
Reference in New Issue