diff --git a/Makefile b/Makefile index f3eec13..409761e 100644 --- a/Makefile +++ b/Makefile @@ -35,19 +35,19 @@ gocui: install forge --gui gocui >/tmp/forge.log 2>&1 private: install - forge find --private + forge list --private fix: install - forge --fix find --all + forge --fix list --all list-all: install forge list --all git-reset: install - forge --do-git-reset find --all + forge --do-git-reset list --all readonly: install - forge --list find --readonly + forge --list list --readonly config: install forge --config @@ -74,7 +74,7 @@ patches-list: install forge --list-patchset dirty: install - forge --no-gui find --all --dirty + forge dirty --all restart: reset diff --git a/argv.go b/argv.go index 9d15e00..7c19ed4 100644 --- a/argv.go +++ b/argv.go @@ -7,33 +7,31 @@ package main var argv args type FindCmd struct { - All bool `arg:"--all" help:"select every repo"` - ReadOnly bool `arg:"--readonly" help:"include read-only repos"` + All bool `arg:"--all" help:"select every repo (the default)"` Mine bool `arg:"--mine" help:"your repos as defined in the forge config"` Favorites bool `arg:"--favorites" help:"your repos configured as favorites"` - Private bool `arg:"--private" help:"private repos from your .config/forge/"` + Private bool `arg:"--private" help:"your private repos from your .config/forge/"` + // ReadOnly bool `arg:"--readonly" help:"include read-only repos"` } type args struct { - Find *FindCmd `arg:"subcommand:find" help:"select repos (for example, --all or --mine)"` List *FindCmd `arg:"subcommand:list" help:"just show a table of the current state"` + Dirty *FindCmd `arg:"subcommand:dirty" help:"check if your git repos are dirty"` User *FindCmd `arg:"subcommand:user" help:"git checkout user"` Devel *FindCmd `arg:"subcommand:devel" help:"git checkout devel"` Master *FindCmd `arg:"subcommand:master" help:"git checkout master"` GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"` - Config bool `arg:"--config" help:"show your .config/forge/ settings"` + Config *FindCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"` ListPatchSet bool `arg:"--list-patchset" help:"list patch sets"` 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"` URL string `arg:"--connect" help:"gowebd url"` Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"` - // List bool `arg:"--list" help:"just show a table of the current state"` - 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()"` - PatchSet string `arg:"--patchset" help:"make patch set"` + 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"` + PatchSet string `arg:"--patchset" help:"make patch set"` } func (args) Version() string { diff --git a/cobol.go b/cobol.go index f2bcfaa..5c54568 100644 --- a/cobol.go +++ b/cobol.go @@ -34,7 +34,7 @@ func doCobol() { log.DaemonMode(true) // log.Info(standardStart5("gopath", "cur name", "master", "user", "repo type")) - log.Info(standardStart8("gopath", "cur name", "age", "target", "master", "devel", "user", "curver", "repo type")) + log.Info(standardStart8("repopath", "cur name", "age", "target", "master", "devel", "user", "curver", "repo type")) all := me.found.SortByFullPath() for all.Scan() { repo := all.Next() @@ -133,28 +133,32 @@ func verifyPrint(repo *gitpb.Repo) { if repo.IsDirty() { end += "(dirty) " } - s := make(map[string]string) - if !verify(repo, s) { - log.Info("going to delete", repo.GetGoPath()) - if argv.Fix { - me.forge.DeleteByGoPath(repo.GetGoPath()) - me.forge.Repos.ConfigSave() - } else { - log.Info("need argv --fix to delete", repo.GetGoPath()) + // s := make(map[string]string) + /* + if !verify(repo, s) { + log.Info("going to delete", repo.GetGoPath()) + if argv.Fix { + me.forge.DeleteByGoPath(repo.GetGoPath()) + me.forge.Repos.ConfigSave() + } else { + log.Info("need argv --fix to delete", repo.GetGoPath()) + } } - } + */ - var mhort string = s["mver"] // master version - var dhort string = s["dver"] // devel version - var uhort string = s["uver"] // user version - var thort string = s["tver"] // target version - var chort string = s["cver"] // current version - var cname string = s["cname"] // current branch name git is on now + var mhort string = repo.GetMasterVersion() + var dhort string = repo.GetDevelVersion() + var uhort string = repo.GetUserVersion() + var thort string = repo.GetTargetVersion() + var chort string = repo.GetCurrentBranchVersion() + var cname string = repo.GetCurrentBranchName() + + var gopath string = repo.GetGoPath() + var rtype string = repo.GetRepoType() age := shell.FormatDuration(repo.NewestAge()) - // start := fmt.Sprintf("%-40s %-12s %-12s %-12s %-8s", s["gopath"], cname, mhort, uhort, s["rtype"]) - start := standardStart8(s["gopath"], cname, age, thort, mhort, dhort, uhort, chort, s["rtype"]) + start := standardStart8(gopath, cname, age, thort, mhort, dhort, uhort, chort, rtype) if me.forge.Config.IsReadOnly(repo.GetGoPath()) { end += "(readonly) " diff --git a/doCommon.go b/doCommon.go index e172f48..d3a2ad2 100644 --- a/doCommon.go +++ b/doCommon.go @@ -39,7 +39,7 @@ func doGitPull() { func doCheckDirty() { now := time.Now() - all := me.forge.Repos.SortByFullPath() + all := me.found.SortByFullPath() for all.Scan() { repo := all.Next() dirty := repo.IsDirty() diff --git a/findConfig.go b/findConfig.go index aba8709..6703adf 100644 --- a/findConfig.go +++ b/findConfig.go @@ -3,23 +3,20 @@ package main import "go.wit.com/log" // retuns true if nothing was done -func findConfig() bool { - var done bool = false - if argv.Find != nil { - if argv.Find.Mine { - findConfigMine() - done = true - } - if argv.Find.All { - findConfigAll() - done = true - } - } - if !done { +func findConfig(fargv *FindCmd) { + if fargv == nil { findConfigAll() - done = true + return } - return done + if fargv.Mine { + findConfigMine() + return + } + if fargv.All { + findConfigAll() + return + } + findConfigAll() } // finds config repos that are writable diff --git a/findRepos.go b/findRepos.go index 8739d29..a55c2c3 100644 --- a/findRepos.go +++ b/findRepos.go @@ -1,9 +1,6 @@ package main -import ( - "go.wit.com/log" -) - +// by default, work against every repo func (f *FindCmd) findRepos() { if f == nil { findMine() @@ -29,7 +26,7 @@ func (f *FindCmd) findRepos() { return } - findMine() + findAll(f) } func findRepos(fargv *FindCmd) { @@ -93,26 +90,10 @@ func findFavorites() { } } -// func (f *FindCmd) findRepos() { func findAll(fargv *FindCmd) { all := me.forge.Repos.SortByFullPath() for all.Scan() { repo := all.Next() me.found.AppendUniqueGoPath(repo) - if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !fargv.ReadOnly { - if repo.ReadOnly { - continue - } - log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GetGoPath()) - repo.ReadOnly = true - configSave = true - continue - } } - /* - if configsave { - log.Info("should ConfigSave here") - me.forge.Repos.ConfigSave() - } - */ } diff --git a/main.go b/main.go index 20f2930..1c2db96 100644 --- a/main.go +++ b/main.go @@ -87,26 +87,25 @@ func main() { } // first find the repos or gopaths to operate on - if argv.Config { - if findConfig() { - me.forge.ConfigPrintTable() - okExit("") - } + if argv.Config != nil { + findConfig(argv.Config) + me.forge.ConfigPrintTable() + okExit("") } log.Info("found", me.found.Len(), "repos. found", len(me.foundPaths), "paths from .config/forge") // now, do something to all of them (or just print out a table of them) var done bool = false - if argv.Dirty { - findRepos(argv.Find) + if argv.Dirty != nil { + argv.Dirty.findRepos() doCheckDirty() okExit("") done = true } if argv.Scan { - findRepos(argv.Find) + findRepos(argv.List) doScan() done = true } @@ -118,7 +117,7 @@ func main() { } if argv.GitReset { - findRepos(argv.Find) + findRepos(argv.List) doGitReset() done = true }