summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go7
-rw-r--r--argvAutoshell.go10
-rw-r--r--doVerifyDevel.go90
-rw-r--r--main.go6
4 files changed, 109 insertions, 4 deletions
diff --git a/argv.go b/argv.go
index e05abf4..57058e9 100644
--- a/argv.go
+++ b/argv.go
@@ -48,6 +48,13 @@ type CleanCmd struct {
Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"`
GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"`
User *EmptyCmd `arg:"subcommand:user" help:"clean the user branches"`
+ Verify *VerifyCmd `arg:"subcommand:verify" help:"verify branches"`
+}
+
+type VerifyCmd struct {
+ User *FindCmd `arg:"subcommand:user" help:"verify the user branches"`
+ Devel *FindCmd `arg:"subcommand:devel" help:"verify the devel branches"`
+ Master *FindCmd `arg:"subcommand:master" help:"verify the master branches"`
}
type CleanDevelCmd struct {
diff --git a/argvAutoshell.go b/argvAutoshell.go
index b97218f..e54738a 100644
--- a/argvAutoshell.go
+++ b/argvAutoshell.go
@@ -13,7 +13,7 @@ import (
// used for shell auto completion
// var ARGNAME string = "forge" // todo: get this from $0 ?
-func (a *EmptyCmd) deleteMatch() {
+func deleteMatch() {
// f := forgedb.InitSimple()
fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this")
}
@@ -29,13 +29,13 @@ func (args) doBashAuto() {
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
- fmt.Println("delete devel force examine force git-reset user")
+ fmt.Println("delete devel force examine force git-reset user verify")
case "commit":
fmt.Println("--all")
case "config":
fmt.Println("add fix list")
case "delete":
- argv.Clean.Delete.deleteMatch()
+ deleteMatch()
case "dirty":
fmt.Println("--verbose")
case "examine":
@@ -49,9 +49,11 @@ func (args) doBashAuto() {
case "user":
fmt.Println("--force")
case "devel":
- fmt.Println("--force")
+ fmt.Println("--verbose")
case "master":
fmt.Println("--force")
+ case "verify":
+ fmt.Println("user devel master")
default:
if argv.BashAuto[0] == ARGNAME {
// list the subcommands here
diff --git a/doVerifyDevel.go b/doVerifyDevel.go
new file mode 100644
index 0000000..b8fd419
--- /dev/null
+++ b/doVerifyDevel.go
@@ -0,0 +1,90 @@
+package main
+
+import (
+ "path/filepath"
+
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func doVerifyDevel() error {
+ me.found = new(gitpb.Repos)
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ if repo.IsDirty() {
+ log.Info(repo.GetGoPath(), "is dirty")
+ continue
+ }
+ if repo.GetDevelBranchName() == "" {
+ continue
+ }
+ if repo.GetMasterBranchName() != repo.GetCurrentBranchName() {
+ log.Info(repo.GetGoPath(), "is not on master branch")
+ continue
+ }
+
+ // check if devel branch exists in remote repo
+ devel := repo.GetDevelBranchName()
+ if argv.Verbose {
+ log.Printf("Start clean devel branch: %s %s\n", repo.GetGoPath(), devel)
+ }
+
+ if repo.Exists(filepath.Join(".git/refs/remotes/origin", devel)) {
+ // todo: actually use .git/config
+ if err := doCleanDevelRepo(repo); err != nil {
+ log.Info(repo.GetGoPath(), "verify clean failed")
+ }
+ // can not continue
+ continue
+ }
+ // devel branch is only local
+ /*
+ devname := repo.GetDevelBranchName()
+ if err := requiresGitPush(repo, devname); err != nil {
+ log.Info(repo.GetGoPath(), "is out of sync with upstream")
+ return err
+ }
+ */
+ }
+ return nil
+}
+
+/*
+ err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname)
+ log.Info(err)
+ cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName())
+ if argv.Clean.Examine.Fix == nil {
+ log.Info(repo.GetGoPath(), cmd)
+ } else {
+ if _, err := repo.RunVerbose(cmd); err != nil {
+ return err
+ }
+ }
+ cmd = repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.CurrentTag.Refname)
+ if argv.Clean.Examine.Fix == nil {
+ log.Info(repo.GetGoPath(), cmd)
+ } else {
+ if _, err := repo.RunVerbose(cmd); err != nil {
+ return err
+ }
+ }
+ cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname}
+ log.Info(repo.GetGoPath(), "TRY THIS:", cmd)
+ if argv.Clean.Examine.Fix == nil {
+ log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
+ repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
+ } else {
+ log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
+ if _, err := repo.RunVerbose(cmd); err != nil {
+ return err
+ } else {
+ return nil
+ }
+ }
+ return err
+ }
+ err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
+ log.Info(err)
+ return nil
+*/
diff --git a/main.go b/main.go
index 7751b8c..3030314 100644
--- a/main.go
+++ b/main.go
@@ -85,12 +85,18 @@ func main() {
}
okExit("")
}
+
if argv.Clean.GitReset != nil {
findAll() // select all the repos
doGitReset()
okExit("reset")
}
+ if argv.Clean.Verify != nil {
+ doVerifyDevel()
+ okExit("verify")
+ }
+
if err := doClean(); err != nil {
badExit(err)
}