From ce813a345030dffa9d997cb837cc8be99b9c5946 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 8 Sep 2025 13:48:06 -0500 Subject: [PATCH] common code. add "gui" to open the gui --- argv.go | 1 + doNormal.go | 2 +- doPatch.go | 14 +++++++++++--- main.go | 17 ++++++++++++++--- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/argv.go b/argv.go index 62f7aec..63c66c6 100644 --- a/argv.go +++ b/argv.go @@ -23,6 +23,7 @@ type args struct { Debug *EmptyCmd `arg:"subcommand:debug" help:"debug forge"` Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"` + Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"` Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` Normal *NormalCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` diff --git a/doNormal.go b/doNormal.go index 21d7c2f..7684e15 100644 --- a/doNormal.go +++ b/doNormal.go @@ -34,7 +34,7 @@ func doNormal() bool { if count > 0 { log.Info("Some repos are not in a 'normal' state. error count =", count) log.Info("TODO: list the repos here. forge patch repos?") - dumpDirtyRepos() + dumpWorkRepos() configSave = true return false } diff --git a/doPatch.go b/doPatch.go index c1e301b..63d6323 100644 --- a/doPatch.go +++ b/doPatch.go @@ -51,7 +51,7 @@ func doPatchSubmit() error { func doPatch() error { if argv.Patch.Repos != nil { - dumpDirtyRepos() + dumpWorkRepos() return nil } @@ -156,11 +156,17 @@ func doPatch() error { // if nothing, show patches & dirty repos me.forge.Patchsets.PrintTable() - dumpDirtyRepos() + dumpWorkRepos() return nil } -func dumpDirtyRepos() { +// Shows repos that are: +// - git dirty repos +// - repos with 'user' branch patches not in 'devel' branch +// - repos with awaiting master branch verions +// +// return true if any are found +func dumpWorkRepos() bool { // always run dirty first me.forge.CheckDirtyQuiet() @@ -169,9 +175,11 @@ func dumpDirtyRepos() { found := findReposWithPatches() if found.Len() == 0 { log.Info("you currently have no repos with patches") + return false } else { me.forge.PrintHumanTable(found) } + return true } // returns bad if patches can not be applied diff --git a/main.go b/main.go index af7741d..cd4185b 100644 --- a/main.go +++ b/main.go @@ -257,9 +257,20 @@ func main() { // open the gui unless the user performed some other // basically, if you run just 'forge' it should open the GUI - // if opening the GUI, always check git for dirty repos - me.forge.CheckDirty() - doGui() + if argv.Gui != nil { + // if opening the GUI, always check git for dirty repos + me.forge.CheckDirty() + doGui() + } + // got to the end with nothing to do (?) + if dumpWorkRepos() { + // found some repos at least + } else { + // every repo is in a really clean state. no extra files anywhere + // no dirty repos, no repos that need to be published + // nothing different between user and master branch version. not common + log.Info("All of your git repositories appear to be in perfect shape") + } okExit("") }