From 9bcf2d968c7565516ee55c4473670a888f36b3f7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 28 Aug 2025 10:11:31 -0500 Subject: [PATCH] add "forge normal" to reset things to default development state --- argv.go | 1 + argvAutoshell.go | 2 +- doDirty.go | 22 +--------------------- doGui.go | 9 +++++++++ doNormal.go | 37 +++++++++++++++++++++++++++++++++++++ main.go | 5 +++++ windowPublish.go | 41 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 doNormal.go create mode 100644 windowPublish.go diff --git a/argv.go b/argv.go index 9b7601b..6baab59 100644 --- a/argv.go +++ b/argv.go @@ -23,6 +23,7 @@ type args struct { Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"` List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"` + Normal *EmptyCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"` Pull *PullCmd `arg:"subcommand:pull" help:"run 'git pull'"` diff --git a/argvAutoshell.go b/argvAutoshell.go index 8c34d68..afceaa0 100644 --- a/argvAutoshell.go +++ b/argvAutoshell.go @@ -66,7 +66,7 @@ func (args) doBashAuto() { default: if argv.BashAuto[0] == ARGNAME { // list the subcommands here - fmt.Println("--bash list checkout clean commit dirty debug fetch merge patch pull") + fmt.Println("--bash list checkout clean commit dirty debug fetch normal merge patch pull") } } os.Exit(0) diff --git a/doDirty.go b/doDirty.go index f4373d9..a2a38ec 100644 --- a/doDirty.go +++ b/doDirty.go @@ -13,12 +13,7 @@ import ( func doDirty() { doCheckDirtyAndConfigSave() - if allerr := me.forge.RillRepos(checkNormalRepoState); len(allerr) != 0 { - log.Info("Some repos are not in a 'normal' state. error count =", len(allerr)) - for repo, err := range allerr { - log.Info("repo not normal", repo.GetFullPath(), err) - } - } + found := findDirty() if found.Len() == 0 { return @@ -30,21 +25,6 @@ func doDirty() { } } -// 99% of the time, the repos during development should be on your user branch. -// error out if it's not -// this checks to see if a devel and user branch exist -// this needs to run each time in case repos were added manually by the user -// this also verifies that -func checkNormalRepoState(repo *gitpb.Repo) error { - if _, err := repo.MakeLocalDevelBranch(); err != nil { - return err - } - if repo.GetCurrentBranchName() != repo.GetUserBranchName() { - return repo.CheckoutUser() - } - return nil -} - func straightCheckDirty() int { var count int // var total int diff --git a/doGui.go b/doGui.go index dafd4c9..3b129bd 100644 --- a/doGui.go +++ b/doGui.go @@ -167,6 +167,15 @@ func drawWindow(win *gadgets.GenericWindow) { patchesWin = makePatchesWin(notdone) }) + var pubWin *gadgets.GenericWindow + gridM.NewButton("Publish", func() { + if pubWin != nil { + pubWin.Toggle() + return + } + pubWin = makePublishWindow() + }) + var oldWin *gadgets.GenericWindow gridM.NewButton("old", func() { if oldWin != nil { diff --git a/doNormal.go b/doNormal.go new file mode 100644 index 0000000..c85c8df --- /dev/null +++ b/doNormal.go @@ -0,0 +1,37 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +// checks that repos are in a "normal" state + +import ( + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +func doNormal() bool { + if allerr := me.forge.RillRepos(checkNormalRepoState); len(allerr) != 0 { + log.Info("Some repos are not in a 'normal' state. error count =", len(allerr)) + for repo, err := range allerr { + log.Info("repo not normal", repo.GetFullPath(), err) + } + return false + } + return true +} + +// 99% of the time, the repos during development should be on your user branch. +// error out if it's not +// this checks to see if a devel and user branch exist +// this needs to run each time in case repos were added manually by the user +// this also verifies that +func checkNormalRepoState(repo *gitpb.Repo) error { + if _, err := repo.MakeLocalDevelBranch(); err != nil { + return err + } + if repo.GetCurrentBranchName() != repo.GetUserBranchName() { + return repo.CheckoutUser() + } + return nil +} diff --git a/main.go b/main.go index 645b41b..68b7016 100644 --- a/main.go +++ b/main.go @@ -129,6 +129,11 @@ func main() { okExit("") } + if argv.Normal != nil { + doNormal() + okExit("") + } + if argv.Dirty != nil { doDirty() okExit("") diff --git a/windowPublish.go b/windowPublish.go new file mode 100644 index 0000000..7e1e956 --- /dev/null +++ b/windowPublish.go @@ -0,0 +1,41 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +// An app to submit patches for the 30 GO GUI repos + +import ( + "go.wit.com/lib/gadgets" + "go.wit.com/log" +) + +// Publish Window +func makePublishWindow() *gadgets.GenericWindow { + pubWin := gadgets.NewGenericWindow("publish code", "tasks for merging, versioning and publishing code") + + grid := pubWin.Group.RawGrid() + + grid.NewButton("merge all patches to master", func() { + pubWin.Disable() + defer pubWin.Enable() + + if err := doAllCheckoutDevel(); err != nil { + log.Info("checkout error:", err) + } else { + log.Info("checkout was ok") + } + + mergeUserToDevel(true) + + if err := doAllCheckoutMaster(); err != nil { + log.Info("checkout error:", err) + } else { + log.Info("checkout was ok") + } + + mergeDevelToMaster(true) + }) + + return pubWin +}