diff --git a/argv.go b/argv.go index b85a476..a9ba18a 100644 --- a/argv.go +++ b/argv.go @@ -47,6 +47,7 @@ type CleanCmd struct { Examine *ExamineCmd `arg:"subcommand:examine" help:"examine branches"` Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"` GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"` + Pub *EmptyCmd `arg:"subcommand:pub" help:"clean target version numbers"` User *EmptyCmd `arg:"subcommand:user" help:"clean the user branches"` Verify *VerifyCmd `arg:"subcommand:verify" help:"verify branches"` Repo string `arg:"--repo" help:"which repo to look at"` @@ -101,12 +102,13 @@ type DirtyCmd struct { } type FindCmd 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/"` - Dirty bool `arg:"--dirty" help:"only use dirty git repos"` - User bool `arg:"--user" help:"show repos on the user branch"` + Pub *EmptyCmd `arg:"subcommand:pub" help:"fix .config/forge/ and/or repos.pb protobuf file"` + 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/"` + Dirty bool `arg:"--dirty" help:"only use dirty git repos"` + User bool `arg:"--user" help:"show repos on the user branch"` // ReadOnly bool `arg:"--readonly" help:"include read-only repos"` } diff --git a/argvAutoshell.go b/argvAutoshell.go index caef069..ba1d983 100644 --- a/argvAutoshell.go +++ b/argvAutoshell.go @@ -39,7 +39,7 @@ func (args) doBashAuto() { case "examine": fmt.Println("fix") case "list": - fmt.Println("--all --mine --favorites --private") + fmt.Println("--all --mine --favorites --private pub") case "pull": fmt.Println("--verbose") case "patch": diff --git a/doClean.go b/doClean.go index 9955c5c..7c7145e 100644 --- a/doClean.go +++ b/doClean.go @@ -14,6 +14,13 @@ var ErrorMergeBranch error = fmt.Errorf("trunk has things not in the branch") var ErrorMergeTrunk error = fmt.Errorf("branch has things not in trunk") func doClean() error { + if argv.Clean.Pub != nil { + if err := doCleanPub(); err != nil { + badExit(err) + } + log.Info("finished attempt at cleaning devel branches") + return nil + } if argv.Clean.Devel != nil { if err := doCleanDevel(); err != nil { badExit(err) @@ -535,3 +542,18 @@ func countGitDiffLog(repo *gitpb.Repo, branch1, branch2 string) int { // log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " ")) return len(r.Stdout) } + +func doCleanPub() error { + total := 0 + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.GetTargetVersion() != "" { + repo.SetTargetVersion("") + configSave = true + total += 1 + } + } + log.Printf("clearing %d total repos\n", total) + return nil +} diff --git a/find.go b/find.go index 31659db..04824af 100644 --- a/find.go +++ b/find.go @@ -17,6 +17,11 @@ func (f *FindCmd) findRepos() { return } + if f.Pub != nil { + findPublishable() + return + } + if f.All { findAll() return @@ -114,6 +119,17 @@ func findUser() { } } +func findPublishable() { + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.GetTargetVersion() == "" { + continue + } + me.found.AppendByGoPath(repo) + } +} + func findReposWithPatches() { all := me.forge.Repos.SortByFullPath() for all.Scan() {