diff --git a/Makefile b/Makefile index ef0dbb1..39a5522 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ patches-list: install forge --list-patches --url "http://localhost:2233/" dirty: install - forge --dirty + forge do --dirty restart: reset diff --git a/argv.go b/argv.go index 8eed65e..391065a 100644 --- a/argv.go +++ b/argv.go @@ -20,6 +20,7 @@ type DoCmd struct { GitReset bool `arg:"--git-reset" help:"run 'git reset --hard'"` Scan bool `arg:"--scan" help:"reload protobuf from .git/"` Force bool `arg:"--force" help:"force redo things"` + Dirty bool `arg:"--dirty" help:"update git CheckDirty()"` } type args struct { @@ -31,7 +32,6 @@ type args struct { DryRun bool `arg:"--dry-run" help:"show what would be run"` Fix bool `arg:"--fix" help:"fix config, save config & exit"` Delete string `arg:"--delete" help:"delete this repo"` - Dirty bool `arg:"--dirty" help:"git CheckDirty() on every repo"` User bool `arg:"--user" help:"git checkout user"` Devel bool `arg:"--devel" help:"git checkout devel"` Master bool `arg:"--master" help:"git checkout master"` @@ -59,5 +59,3 @@ Examples: # these options are intended for automation. You probably just want to use the GUI. ` } - -// forge --map lib/foo https://github.com/me/myfoo # map go.wit.com/lib/foo -> github.com/me/myfoo diff --git a/doCommon.go b/doCommon.go index ef58738..76c591a 100644 --- a/doCommon.go +++ b/doCommon.go @@ -1,6 +1,9 @@ package main import ( + "time" + + "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) @@ -33,6 +36,29 @@ func doGitPull() { } } + +func doCheckDirty() { + now := time.Now() + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + dirty := repo.IsDirty() + if repo.CheckDirty() { + me.found.AppendUniqueGoPath(repo) + if !dirty { + configSave = true + } + } else { + if dirty { + configSave = true + } + } + } + doCobol() + log.Info("dirty check took:", shell.FormatDuration(time.Since(now))) + me.forge.SetConfigSave(configSave) +} + func doGitReset() { all := me.found.SortByFullPath() for all.Scan() { diff --git a/main.go b/main.go index cb3b4a8..3db4737 100644 --- a/main.go +++ b/main.go @@ -4,11 +4,9 @@ package main import ( "strings" - "time" "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" - "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -40,11 +38,6 @@ func main() { me.forge = forgepb.Init() me.found = new(gitpb.Repos) - if configSave { - me.forge.ConfigSave() - configSave = false - } - if argv.User { me.forge.CheckoutUser() okExit("") @@ -69,38 +62,6 @@ func main() { okExit("") } - if argv.Dirty { - now := time.Now() - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - dirty := repo.IsDirty() - if repo.CheckDirty() { - me.found.AppendUniqueGoPath(repo) - if !dirty { - configSave = true - } - } else { - if dirty { - configSave = true - } - } - } - doCobol() - log.Info("dirty check took:", shell.FormatDuration(time.Since(now))) - me.forge.SetConfigSave(configSave) - okExit("") - } - - /* - // var count int - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - verifyPrint(repo) - } - */ - if argv.Fix { okExit("") } @@ -121,6 +82,12 @@ func main() { // now, do something to all of them (or just print out a table of them) var done bool = false if argv.Do != nil { + if argv.Do.Dirty { + doCheckDirty() + okExit("") + done = true + } + if argv.Do.Scan { doScan() done = true @@ -154,6 +121,11 @@ func main() { okExit("patches") } + if configSave { + me.forge.ConfigSave() + configSave = false + } + // if the user doesn't want to open the GUI and // nothing else was specified to be done, // then just list the table to stdout