diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | argv.go | 97 | ||||
| -rw-r--r-- | doClean.go | 30 | ||||
| -rw-r--r-- | doFind.go | 12 | ||||
| -rw-r--r-- | doPull.go | 40 |
5 files changed, 89 insertions, 92 deletions
@@ -9,7 +9,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M) default: install-verbose tag tag: - forge tag list + forge show tag vet: @GO111MODULE=off go vet @@ -33,19 +33,22 @@ type args struct { } type ShowCmd struct { - Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` - List *EmptyCmd `arg:"subcommand:list" help:"print a table of the current repos"` - Tag *TagCmd `arg:"subcommand:tag" help:"manage git tags"` - Build string `arg:"--build" help:"build a repo"` - Install string `arg:"--install" help:"install a repo"` - BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"` - URL string `arg:"--connect" help:"forge url"` - 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:"your private repos from your .config/forge/"` - User bool `arg:"--user" help:"show repos on the user branch"` - Full bool `arg:"--full" help:"show full repo names"` + Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` + Repo *RepoCmd `arg:"subcommand:repo" help:"print a table of the current repos"` + Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"` + // Build string `arg:"--build" help:"build a repo"` + // Install string `arg:"--install" help:"install a repo"` + // BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"` + // URL string `arg:"--connect" help:"forge url"` +} + +type RepoCmd struct { + 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:"your private repos from your .config/forge/"` + User bool `arg:"--user" help:"show repos on the user branch"` + Full bool `arg:"--full" help:"show full repo names"` // ReadOnly bool `arg:"--readonly" help:"include read-only repos"` } @@ -65,8 +68,8 @@ type CommitCmd struct { type testCmd string type CleanCmd struct { - Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"` - Repo string `arg:"--repo" help:"which repo to look at"` + // Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"` + // Repo string `arg:"--repo" help:"which repo to look at"` } type CleanDevelCmd struct { @@ -87,9 +90,10 @@ type SubmitCmd struct { } type PullCmd struct { - Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"` - Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"` - Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"` + Force bool `arg:"--force" help:"try to strong-arm things"` + // Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"` + // Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"` + // Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"` } type TagCmd struct { @@ -98,21 +102,6 @@ type TagCmd struct { Delete string `arg:"--delete" help:"delete a tag"` } -type ConfigAddCmd struct { - Path string `arg:"--path" help:"absolute path of the git repo"` - GoPath string `arg:"--gopath" help:"GO path of the git repo"` - Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"` - ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"` - Writable bool `arg:"--writable" default:"false" help:"repo is writable"` - Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"` - Private bool `arg:"--private" default:"false" help:"repo can not be published"` - Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"` - DebName string `arg:"--debname" help:"the name of the debian package (or rpm, etc)"` - Master string `arg:"--master" help:"the git 'master' or 'main' branch name"` - Devel string `arg:"--devel" help:"the git devel branch name"` - User string `arg:"--user" help:"the git user branch name"` -} - type CheckoutCmd struct { User *EmptyCmd `arg:"subcommand:user" help:"git checkout user"` Devel *EmptyCmd `arg:"subcommand:devel" help:"git checkout devel"` @@ -120,9 +109,10 @@ type CheckoutCmd struct { } type MergeCmd struct { + All bool `arg:"--all" help:"merge all"` Devel *EmptyCmd `arg:"subcommand:devel" help:"merge user to devel"` Master *EmptyCmd `arg:"subcommand:master" help:"merge devel to master"` - Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"` + Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"` } type ConfigCmd struct { @@ -133,6 +123,21 @@ type ConfigCmd struct { Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"` } +type ConfigAddCmd struct { + Path string `arg:"--path" help:"absolute path of the git repo"` + GoPath string `arg:"--gopath" help:"GO path of the git repo"` + Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"` + ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"` + Writable bool `arg:"--writable" default:"false" help:"repo is writable"` + Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"` + Private bool `arg:"--private" default:"false" help:"repo can not be published"` + Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"` + DebName string `arg:"--debname" help:"the name of the debian package (or rpm, etc)"` + Master string `arg:"--master" help:"the git 'master' or 'main' branch name"` + Devel string `arg:"--devel" help:"the git devel branch name"` + User string `arg:"--user" help:"the git user branch name"` +} + func (args) Version() string { return ARGNAME + " " + VERSION + " Built on " + BUILDTIME } @@ -163,21 +168,6 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. ` } -// handles shell autocomplete -func DoAutoComplete(pb *prep.Auto) { - switch pb.Cmd { - case "show": - pb.SubCommand(pb.Cmd) - default: - if pb.Cmd == "" { - pb.Autocomplete2("checkout clean commit normal merge show") - } else { - pb.SubCommand(pb.Cmd) - } - } - os.Exit(0) -} - func (args) Appname() string { return ARGNAME } @@ -190,6 +180,11 @@ func ifBlank(arg string) bool { return false } -func (a args) DoAutoComplete(autoArgv *prep.Auto) { - DoAutoComplete(autoArgv) +func (a args) DoAutoComplete(pb *prep.Auto) { + if pb.Cmd == "" { + pb.Autocomplete3([]string{"checkout", "clean", "commit", "config", "gui", "merge", "normal", "patch", "pull", "show"}) + } else { + pb.SubCommand(pb.Argv...) + } + os.Exit(0) } @@ -6,9 +6,7 @@ package main import ( "fmt" "path/filepath" - "time" - "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -58,21 +56,23 @@ if repo.IsSubset("user", "devel") { func doClean() error { setForgeMode(forgepb.ForgeMode_CLEAN) - if argv.Clean.Verify != nil { - stats := me.forge.RillRepos(checkRemoteBranches) - for path, stat := range stats { - if stat.Err == nil { - continue - } - dur := stat.End.Sub(stat.Start) - if dur > time.Second { - log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err) + /* + if argv.Clean.Verify != nil { + stats := me.forge.RillRepos(checkRemoteBranches) + for path, stat := range stats { + if stat.Err == nil { + continue + } + dur := stat.End.Sub(stat.Start) + if dur > time.Second { + log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err) + } } + // log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path) + // log.Infof("%-30v %s %v\n", dur, path, stat.Err) + return nil } - // log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path) - // log.Infof("%-30v %s %v\n", dur, path, stat.Err) - return nil - } + */ // fix this to work, then delete all the other options for "forge clean' if err := me.forge.DoAllCheckoutMaster(); err != nil { @@ -19,7 +19,7 @@ func doFind() *gitpb.Repos { return findAll() } - if argv.Show.Mine { + if argv.Show.Repo.Mine { return findMine() } @@ -35,19 +35,19 @@ func findRepos() *gitpb.Repos { return findMine() } - if argv.Show.All { + if argv.Show.Repo.All { return findAll() } - if argv.Show.Private { + if argv.Show.Repo.Private { return findPrivate() } - if argv.Show.Mine { + if argv.Show.Repo.Mine { return findMine() } - if argv.Show.Favorites { + if argv.Show.Repo.Favorites { return findFavorites() } @@ -55,7 +55,7 @@ func findRepos() *gitpb.Repos { return me.forge.FindDirty() } - if argv.Show.User { + if argv.Show.Repo.User { return findUser() } @@ -14,26 +14,28 @@ import ( // is every repo on the devel branch? func doPull() error { - if argv.Pull.Check != nil { - // stats := me.forge.RillFuncError(rillPull) - log.Info("TODO: actually git pull here? this is a bad idea. stopping.") - submit := gitpb.NewRepos() - for repo := range me.forge.Repos.IterByFullPath() { - newrepo := new(gitpb.Repo) - newrepo.MasterHash = repo.MasterHash - newrepo.DevelHash = repo.DevelHash - newrepo.Namespace = repo.Namespace - newrepo.URL = repo.URL - submit.Append(newrepo) - } - updatepb, regPB, err := submit.HttpPost(myServer(), "check") - if regPB == nil || err != nil { - log.Info("regPB==nil or err:", err) + /* + if argv.Pull.Check != nil { + // stats := me.forge.RillFuncError(rillPull) + log.Info("TODO: actually git pull here? this is a bad idea. stopping.") + submit := gitpb.NewRepos() + for repo := range me.forge.Repos.IterByFullPath() { + newrepo := new(gitpb.Repo) + newrepo.MasterHash = repo.MasterHash + newrepo.DevelHash = repo.DevelHash + newrepo.Namespace = repo.Namespace + newrepo.URL = repo.URL + submit.Append(newrepo) + } + updatepb, regPB, err := submit.HttpPost(myServer(), "check") + if regPB == nil || err != nil { + log.Info("regPB==nil or err:", err) + return nil + } + log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err) return nil } - log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err) - return nil - } + */ // below this, you must not be in 'normal' mode if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL { @@ -41,7 +43,7 @@ func doPull() error { return nil } - if argv.Force == true { + if argv.Pull.Force { now := time.Now() stats := me.forge.RillFuncError(rillPull) count := me.forge.RillReload() |
