From 060c304a43ede89600e7ca46e83d4602eb12d890 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 22 Sep 2025 21:07:32 -0500 Subject: [PATCH] forgot to set Username on init() --- config.go | 6 ------ init.go | 5 +++++ repoNew.go | 6 ++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index 8442933..fd2f94e 100644 --- a/config.go +++ b/config.go @@ -72,12 +72,6 @@ func (cfg *ForgeConfigs) DumpENV() { } /* - if f.Config.Username == "" { - usr, _ := user.Current() - f.Config.Username = usr.Username - f.SetConfigSave(true) - } - if f.Config.Xterm == "" { f.Config.Xterm = "xterm" f.Config.XtermArgv = append(f.Config.XtermArgv, "-bg") diff --git a/init.go b/init.go index 9243e9d..f43122c 100644 --- a/init.go +++ b/init.go @@ -4,6 +4,7 @@ package forgepb import ( "os" + "os/user" "path/filepath" "go.wit.com/lib/config" @@ -40,6 +41,10 @@ func Init() *Forge { f.Config.DumpENV() return f } + if f.Config.Username == "" { + usr, _ := user.Current() + f.Config.Username = usr.Username + } f.initFromConfig() if f.Config.Mode == ForgeMode_MASTER { log.Printf("forge.Init() %s len()=%d\n", f.Config.Filename, f.Repos.Len()) diff --git a/repoNew.go b/repoNew.go index 377d35a..9f3f1f5 100644 --- a/repoNew.go +++ b/repoNew.go @@ -164,6 +164,9 @@ func (f *Forge) VerifyBranchNames(repo *gitpb.Repo) { if repo.GetUserBranchName() == "" { uname := f.configUserBranchName(repo) + if uname == "" { + log.Info("configUserBranchName() ERROR: failed with blank") + } if repo.IsBranch(uname) { repo.SetUserBranchName(uname) } else { @@ -189,6 +192,9 @@ func (f *Forge) configUserBranchName(repo *gitpb.Repo) string { if uname != "" { return uname } + if f.Config.Username == "" { + // something is wrong! + } // use the os.Username uname = f.Config.Username