set default branch names
This commit is contained in:
parent
410fee5007
commit
09d9c36f76
1
Makefile
1
Makefile
|
@ -24,6 +24,7 @@ redomod:
|
|||
rm -f go.*
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
go mod edit -go=1.20
|
||||
|
||||
clean:
|
||||
rm -f *.pb.go
|
||||
|
|
93
scanGoSrc.go
93
scanGoSrc.go
|
@ -2,6 +2,7 @@ package forgepb
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -26,7 +27,31 @@ func (f *Forge) ScanGoSrc() (bool, error) {
|
|||
}
|
||||
log.Info("init worked for", newr.GoPath)
|
||||
// try to guess what the 'master' branch is
|
||||
if newr.IsBranch("guimaster") {
|
||||
newr.SetMasterBranchName("guimaster")
|
||||
} else if newr.IsBranch("master") {
|
||||
newr.SetMasterBranchName("master")
|
||||
} else if newr.IsBranch("main") {
|
||||
newr.SetMasterBranchName("main")
|
||||
} else {
|
||||
newr.SetMasterBranchName("masterFIXME")
|
||||
}
|
||||
|
||||
if newr.IsBranch("guidevel") {
|
||||
newr.SetDevelBranchName("guidevel")
|
||||
} else if newr.IsBranch("devel") {
|
||||
newr.SetDevelBranchName("devel")
|
||||
} else {
|
||||
newr.SetDevelBranchName("develFIXME")
|
||||
}
|
||||
|
||||
usr, _ := user.Current()
|
||||
uname := usr.Username
|
||||
if newr.IsBranch(uname) {
|
||||
newr.SetUserBranchName(uname)
|
||||
} else {
|
||||
newr.SetUserBranchName(uname+"FIXME")
|
||||
}
|
||||
} else {
|
||||
log.Log(FORGEPBWARN, "ScanGoSrc() bad:", dir)
|
||||
}
|
||||
|
@ -57,6 +82,16 @@ func gitDirectories(srcDir string) ([]string, error) {
|
|||
return all, err
|
||||
}
|
||||
|
||||
// IsGitDir checks if a .git directory exists inside the given directory
|
||||
func IsGitDir(dir string) bool {
|
||||
gitDir := filepath.Join(dir, ".git")
|
||||
info, err := os.Stat(gitDir)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
/*
|
||||
// rill is awesome. long live rill
|
||||
func rillAddDirs(gopaths []string) {
|
||||
|
@ -81,61 +116,3 @@ func rillAddDirs(gopaths []string) {
|
|||
fmt.Println("Error:", err)
|
||||
}
|
||||
*/
|
||||
|
||||
// IsGitDir checks if a .git directory exists inside the given directory
|
||||
func IsGitDir(dir string) bool {
|
||||
gitDir := filepath.Join(dir, ".git")
|
||||
info, err := os.Stat(gitDir)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
// attempt's to guess at what master is.
|
||||
// TODO: fix this properly
|
||||
func (repo *Repo) guessMainWorkingName() {
|
||||
if repo.IsBranch("guimaster") {
|
||||
return
|
||||
}
|
||||
if repo.IsBranch("master") {
|
||||
return
|
||||
}
|
||||
if rs.TagExists("main") {
|
||||
return
|
||||
}
|
||||
|
||||
// figure out what to do here
|
||||
rs.mainWorkingName.SetText("FIXME")
|
||||
rs.mainBranchVersion.SetLabel("FIXME")
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) guessDevelWorkingName() {
|
||||
if rs.TagExists("guidevel") {
|
||||
rs.develWorkingName.SetValue("guidevel")
|
||||
rs.develBranchVersion.SetLabel("guidevel")
|
||||
return
|
||||
}
|
||||
if rs.TagExists("devel") {
|
||||
rs.develWorkingName.SetValue("devel")
|
||||
rs.develBranchVersion.SetLabel("devel")
|
||||
return
|
||||
}
|
||||
|
||||
// figure out what to do here
|
||||
rs.develWorkingName.SetValue("develFIXME")
|
||||
rs.develBranchVersion.SetLabel("develFIXME")
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) setUserWorkingName() {
|
||||
usr, _ := user.Current()
|
||||
uname := usr.Username
|
||||
if rs.TagExists(uname) {
|
||||
rs.userWorkingName.SetValue(uname)
|
||||
rs.userBranchVersion.SetLabel(uname)
|
||||
return
|
||||
}
|
||||
rs.userWorkingName.SetValue("need to create " + uname)
|
||||
rs.userBranchVersion.SetLabel("need to create " + uname)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue