diff options
| -rw-r--r-- | argv.go | 20 | ||||
| -rw-r--r-- | doShow.go | 39 | ||||
| -rw-r--r-- | doStats.go | 44 |
3 files changed, 73 insertions, 30 deletions
@@ -43,7 +43,6 @@ type ShowCmd struct { ENV *EmptyCmd `arg:"subcommand:ENV" help:"show lib/env"` Tag *TagCmd `arg:"subcommand:refs" help:"show git refs"` Repos *RepoCmd `arg:"subcommand:repos" help:"show repos by type. deprecate."` - Repo string `arg:"--repo" help:"lookup this repo namespace"` // MasterDefault *EmptyCmd `arg:"subcommand:masterdefault" help:"run the default behavior for master branches"` } @@ -66,13 +65,16 @@ type VerifyCmd struct { } type StatsCmd struct { - All bool `arg:"--all" help:"update all stats"` - CheckRefs bool `arg:"--check-refs" help:"load & check refs"` - CheckRemote bool `arg:"--check-refs-remote" help:"load & check remote refs"` - UpdateRefs bool `arg:"--update" help:"update refs"` - UpdateRemote bool `arg:"--update-remote" help:"update remote refs"` - Sizes bool `arg:"--sizes" help:"show sizes"` - List bool `arg:"--list" help:"list all stats"` + All bool `arg:"--all" help:"update all stats"` + CheckRefs bool `arg:"--check-refs" help:"load & check refs"` + CheckRemote bool `arg:"--check-remote" help:"load & check remote log"` + CheckRemoteRefs bool `arg:"--check-remote-refs" help:"load & check remote refs"` + UpdateRefs bool `arg:"--update" help:"update refs"` + UpdateRemote bool `arg:"--update-remote" help:"update remote log"` + UpdateRemoteRefs bool `arg:"--update-remote-refs" help:"update remote refs"` + Sizes bool `arg:"--sizes" help:"show sizes"` + List bool `arg:"--list" help:"list all stats"` + Repo string `arg:"--repo" help:"lookup this repo namespace"` } func (ShowCmd) Examples() string { @@ -109,7 +111,7 @@ type DevCmd struct { GoWork *EmptyCmd `arg:"subcommand:gowork" help:"make a go.work"` Fixer *FixCmd `arg:"subcommand:fixer" help:"send in the fixer"` URL string `arg:"--connect" help:"forge url"` - Stats *StatsCmd `arg:"subcommand:stats" help:"generate origin.pb"` + Stats *StatsCmd `arg:"subcommand:refs" help:"generate stats ref .pb files"` Namespace *EmptyCmd `arg:"subcommand:namespace" help:"check the namespaces"` GitConfig *EmptyCmd `arg:"subcommand:gitconfig" help:"check the .git/config files"` } @@ -4,10 +4,7 @@ package main import ( - "errors" - "go.wit.com/lib/env" - "go.wit.com/log" ) func doShow() (string, error) { @@ -31,26 +28,28 @@ func doShow() (string, error) { return s, err } - if argv.Show.Repo != "" { - r := me.forge.Repos.FindByNamespace(argv.Show.Repo) - if r == nil { - return "no repo " + argv.Show.Repo, errors.New("no repo " + argv.Show.Repo) - } - for _, rmote := range r.Config.Remotes { - stats, err := r.LoadRemoteRefs(rmote.Name) - if err != nil { - // return err + /* + if argv.Show.Repo != "" { + r := me.forge.Repos.FindByNamespace(argv.Show.Repo) + if r == nil { + return "no repo " + argv.Show.Repo, errors.New("no repo " + argv.Show.Repo) } - if env.True("resort") { - stats.SaveByHash() - log.Info("stats should have been resorted and saved") - } else { - footer := stats.PrintTable() - log.Info("full remote refs footer:", footer) + for _, rmote := range r.Config.Remotes { + stats, err := r.LoadRemoteRefs(rmote.Name) + if err != nil { + // return err + } + if env.True("resort") { + stats.SaveByHash() + log.Info("stats should have been resorted and saved") + } else { + footer := stats.PrintTable() + log.Info("full remote refs footer:", footer) + } } + return "remote refs table", nil } - return "remote refs table", nil - } + */ found := findRepos() if showUrls() { @@ -25,6 +25,26 @@ func doStats(cmd *StatsCmd) (string, error) { if repo == nil { return "no repo", errors.New("working dir isn't a repo I know about") } + if cmd.Repo != "" { + r := me.forge.Repos.FindByNamespace(cmd.Repo) + if r == nil { + return "no repo " + cmd.Repo, errors.New("no repo " + cmd.Repo) + } + for _, rmote := range r.Config.Remotes { + stats, err := r.LoadRemoteRefs(rmote.Name) + if err != nil { + // return err + } + if env.True("resort") { + stats.SaveByHash() + log.Info("stats should have been resorted and saved") + } else { + footer := stats.PrintTable() + log.Info("full remote refs footer:", footer) + } + } + return "remote refs table", nil + } if cmd.CheckRefs { err := doCheckRefs(repo) @@ -32,6 +52,11 @@ func doStats(cmd *StatsCmd) (string, error) { } if cmd.CheckRemote { + err := doCheckRemote(repo) + return "checked remote refs", err + } + + if cmd.CheckRemoteRefs { err := doCheckRemoteRefs(repo) return "checked remote refs", err } @@ -41,7 +66,7 @@ func doStats(cmd *StatsCmd) (string, error) { return "update refs", err } - if cmd.UpdateRemote { + if cmd.UpdateRemoteRefs { err := doUpdateRemoteRefs(repo) return "update remote refs", err } @@ -94,6 +119,23 @@ func doUpdateRefs(r *gitpb.Repo) error { return err } +func doCheckRemote(r *gitpb.Repo) error { + for _, rmote := range r.Config.Remotes { + morestats, err := r.MakeRemote(rmote.Name) + if err != nil { + // return err + } + if env.True("resort") { + morestats.SaveByHash() + return errors.New("stats should have been resorted and saved") + } + footer := morestats.PrintTable() + log.Printf("full %s remote refs footer: %s\n", rmote.Name, footer) + } + + return nil +} + func doCheckRemoteRefs(r *gitpb.Repo) error { for _, rmote := range r.Config.Remotes { morestats, err := r.MakeRemoteRefs(rmote.Name) |
