From 410fee50074dd3c77900ee6136f2722f11f5134f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 29 Nov 2024 18:16:06 -0600 Subject: [PATCH] start to move branch name logic here --- Makefile | 4 +--- scanGoSrc.go | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 559a506..3e3f646 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,9 @@ clean: install: make -C forgeConfig install -autogenpb: - autogenpb --proto forgeConfig.proto --sort "ByPath,GoPath" --marshal ForgeConfigs - forgeConfig.pb.go: forgeConfig.proto # I'm using version v1.35.x from google.golang.org/protobuf/cmd/protoc-gen-go cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/lib/protobuf/forgepb \ --go_opt=MforgeConfig.proto=go.wit.com/lib/protobuf/forgepb \ forgeConfig.proto + autogenpb --proto forgeConfig.proto --sort "ByPath,GoPath" --marshal ForgeConfigs diff --git a/scanGoSrc.go b/scanGoSrc.go index 2d6fa76..312c77c 100644 --- a/scanGoSrc.go +++ b/scanGoSrc.go @@ -23,9 +23,10 @@ func (f *Forge) ScanGoSrc() (bool, error) { if err != nil { log.Log(FORGEPBWARN, "init failed", err) panic("crapnuts") - } else { - log.Info("init worked for", newr.GoPath) } + log.Info("init worked for", newr.GoPath) + // try to guess what the 'master' branch is + } else { log.Log(FORGEPBWARN, "ScanGoSrc() bad:", dir) } @@ -90,3 +91,51 @@ func IsGitDir(dir string) bool { } 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) +} +