summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go17
-rw-r--r--doClean.go23
-rw-r--r--main.go12
3 files changed, 29 insertions, 23 deletions
diff --git a/argv.go b/argv.go
index 03e8f6f..7285464 100644
--- a/argv.go
+++ b/argv.go
@@ -52,13 +52,8 @@ type CommitCmd struct {
type testCmd string
type CleanCmd struct {
- Delete *EmptyCmd `arg:"subcommand:delete" help:"rescan repo"`
- Devel *CleanDevelCmd `arg:"subcommand:devel" help:"clean and verify the devel 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"`
- 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 {
@@ -150,8 +145,6 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
//
func DoAutoComplete(argv []string) {
- // fmt.Fprintln(os.Stderr, "") // these are for debugging
- // fmt.Fprintln(os.Stderr, "in autocomplete:", argv) // these are for debugging
switch argv[0] {
case "checkout":
fmt.Println("devel master user")
@@ -160,11 +153,11 @@ func DoAutoComplete(argv []string) {
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
- fmt.Println("--force")
+ fmt.Println("--force verify --repo")
case "commit":
fmt.Println("--all")
case "config":
- fmt.Println("add fix list debug")
+ fmt.Println("add fix list")
case "dirty":
fmt.Println("")
case "gui":
@@ -196,7 +189,7 @@ func DoAutoComplete(argv []string) {
default:
if argv[0] == ARGNAME {
// list the subcommands here
- fmt.Println("help list checkout clean commit dirty debug fetch gui normal merge patch pull")
+ fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull")
}
}
os.Exit(0)
diff --git a/doClean.go b/doClean.go
index 8263d2e..fc04bdc 100644
--- a/doClean.go
+++ b/doClean.go
@@ -7,13 +7,36 @@ import (
"fmt"
"path/filepath"
+ "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
+func checkRemoteBranches(repo *gitpb.Repo) error {
+ if repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
+ repo.Reload()
+ me.forge.SetConfigSave(true)
+ return log.Errorf("devel is bad")
+ }
+ if repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
+ repo.Reload()
+ me.forge.SetConfigSave(true)
+ return log.Errorf("master is bad")
+ }
+ return nil
+}
+
// reverts all repos back to the original master branches
// automatically deletes local devel and user branches
func doClean() error {
+ me.forge.Config.Mode = forgepb.ForgeMode_CLEAN
+
+ if argv.Clean.Verify != nil {
+ stats := me.forge.RillRepos(checkRemoteBranches)
+ _ = stats
+ return nil
+ }
+
// fix this to work, then delete all the other options for "forge clean'
if err := me.forge.DoAllCheckoutMaster(); err != nil {
// badExit(err)
diff --git a/main.go b/main.go
index 9c2f9f8..c7db9d7 100644
--- a/main.go
+++ b/main.go
@@ -50,6 +50,7 @@ func main() {
me.pp = arg.MustParse(&argv)
me.forge = forgepb.Init()
+ me.forge.ScanGoSrc()
// initialize patches
doPatchInit()
@@ -93,17 +94,6 @@ func main() {
}
if argv.Clean != nil {
- me.forge.Config.Mode = forgepb.ForgeMode_CLEAN
- if argv.Clean.Repo != "" {
- log.Info("only looking at repo:", argv.Clean.Repo)
- okExit("")
- }
-
- if argv.Clean.GitReset != nil {
- doGitReset()
- okExit("reset")
- }
-
if err := doClean(); err != nil {
badExit(err)
}