add "forge normal" to reset things to default development state

This commit is contained in:
Jeff Carr 2025-08-28 10:11:31 -05:00
parent a21c117e5b
commit 9bcf2d968c
7 changed files with 95 additions and 22 deletions

View File

@ -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'"`

View File

@ -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)

View File

@ -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

View File

@ -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 {

37
doNormal.go Normal file
View File

@ -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
}

View File

@ -129,6 +129,11 @@ func main() {
okExit("")
}
if argv.Normal != nil {
doNormal()
okExit("")
}
if argv.Dirty != nil {
doDirty()
okExit("")

41
windowPublish.go Normal file
View File

@ -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
}