diff options
| -rw-r--r-- | argv.go | 9 | ||||
| -rw-r--r-- | defaultBehavior.go | 6 | ||||
| -rw-r--r-- | doShow.go | 5 | ||||
| -rw-r--r-- | find.go | 72 |
4 files changed, 84 insertions, 8 deletions
@@ -54,10 +54,11 @@ type EmptyCmd struct { type testCmd string type ShowCmd struct { - Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` - Mtime *EmptyCmd `arg:"subcommand:mtime" help:"show mtime changes"` - Repo *RepoCmd `arg:"subcommand:repos" help:"print a table of the current repos"` - Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"` + Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` + DirtySave *EmptyCmd `arg:"subcommand:dirtysave" help:"check dirty then save"` + Mtime *EmptyCmd `arg:"subcommand:mtime" help:"show mtime changes"` + Repo *RepoCmd `arg:"subcommand:repos" help:"print a table of the current repos"` + Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"` } type FixCmd struct { diff --git a/defaultBehavior.go b/defaultBehavior.go index b42ca34..c9bbeeb 100644 --- a/defaultBehavior.go +++ b/defaultBehavior.go @@ -17,11 +17,13 @@ func defaultBehaviorMaster() error { // if no option is given to patch, list out the // repos that have patches ready in them - found := findReposWithPatches() + found := cloneReposWithPatches() if found.Len() == 0 { log.Info("you currently have no repos with patches") return nil } + footer := found.PrintDefaultTB() + log.Info("default master table", footer) // warn about dirty repos not in master branches for repo := range found.IterAll() { if repo.CheckDirty() { @@ -32,8 +34,6 @@ func defaultBehaviorMaster() error { // return log.Errorf("%s repo is dirty", repo.FullPath) } } - footer := me.forge.PrintDefaultTB(found) - log.Info("default master table", footer) if reallybad { return errors.New("\nYOU ARE MAKING EDITS ON NON USER BRANCHES\n") } @@ -7,7 +7,10 @@ package main func doShow() (string, error) { if argv.Show.Dirty != nil { - // s, err := doDirty() + s, err := doDirty() + return s, err + } + if argv.Show.DirtySave != nil { _, s, err := getDirty() me.forge.Repos.Save() return s, err @@ -5,6 +5,7 @@ package main import ( "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" ) // this populates a slice of protobuf records representing each git repo @@ -195,3 +196,74 @@ func findReposWithPatches() *gitpb.Repos { } return found } + +func cloneReposWithPatches() *gitpb.Repos { + found := gitpb.NewRepos() + + var stop int + + for repo := range me.forge.Repos.IterByFullPath() { + if repo.IsDirty() { + // always add dirty branches + r := found.Clone(repo) + r.State = "is dirty" + repo.State = "is dirty" + continue + } + if repo.GetUserVersion() == "" { + // skip anything without a user branch + if !repo.IsLocalBranchVerbose(repo.GetUserBranchName()) { + // everthing is actually normal + } + stop += 1 + if stop < 5 { + for t := range repo.Tags.IterAll() { + log.Info(repo.Namespace, t.Refname) + } + } else { + panic("stop") + } + // no user branch + r := found.Clone(repo) + r.State = log.Sprintf("no br '%s'", repo.GetUserBranchName()) + continue + } + if repo.GetUserVersion() == "uerr" { + // skip anything without a user branch + r := found.Clone(repo) + r.State = "user == 'uerr'" + continue + } + if repo.GetUserVersion() != repo.GetDevelVersion() { + r := found.Clone(repo) + r.State = "user != dev" + continue + } + + // ignore read-only repos for checks below here + if me.forge.Config.IsReadOnly(repo.Namespace) { + continue + } + + // show anything that differs between 'devel' & 'master' branches + if repo.GetDevelVersion() != repo.GetMasterVersion() { + // this repo.State code isn't great, but it got me here quickly + // I'll defend my code by saying it's faster for me if I do dumb things + // sometimes and fix them later. Probably some employee will have to + // fix this. if that is the case I owe you lunch. or stock options + // log.Info("repo state", repo.FullPath, repo.State) + r := found.Clone(repo) + r.State = "DEVEL behind MASTER" + continue + } + + // this is an old test to see if the current 'last tag' is accurate and should be removed + if repo.GetLastTag() != repo.GetMasterVersion() { + r := found.Clone(repo) + r.FindLastTag() + r.State = "lasttag mismatch" + continue + } + } + return found +} |
