summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--argv.go3
-rw-r--r--argvAutoshell.go2
-rw-r--r--doCheckout.go55
-rw-r--r--doDirty.go44
-rw-r--r--doExamine.go28
-rw-r--r--doPull.go31
-rw-r--r--main.go11
8 files changed, 114 insertions, 63 deletions
diff --git a/Makefile b/Makefile
index 61d6d37..23f818c 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,8 @@ VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
info: install
- forge dirty
+ # forge dirty
+ forge examine
vet:
@GO111MODULE=off go vet
diff --git a/argv.go b/argv.go
index bdc8c43..524b7bb 100644
--- a/argv.go
+++ b/argv.go
@@ -21,7 +21,8 @@ type args struct {
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
Delete *EmptyCmd `arg:"subcommand:delete" help:"untrack a repo"`
- Commit *EmptyCmd `arg:"subcommand:commit" help:"smart 'git commit'"`
+ Commit *EmptyCmd `arg:"subcommand:commit" help:"smart 'git commit' (errors out if on wrong branch)"`
+ Examine *EmptyCmd `arg:"subcommand:examine" help:"examine branches"`
URL string `arg:"--connect" help:"gowebd url"`
All bool `arg:"--all" help:"git commit --all"`
Show string `arg:"--show" help:"show a repo"`
diff --git a/argvAutoshell.go b/argvAutoshell.go
index 76bd21f..2cfc004 100644
--- a/argvAutoshell.go
+++ b/argvAutoshell.go
@@ -46,7 +46,7 @@ func (args) doBashAuto() {
default:
if argv.BashAuto[0] == ARGNAME {
// list the subcommands here
- fmt.Println("--bash checkout commit config dirty delete hard-reset list patch pull rescan")
+ fmt.Println("--bash checkout commit config dirty delete examine hard-reset list patch pull rescan")
}
}
os.Exit(0)
diff --git a/doCheckout.go b/doCheckout.go
index aad0e88..6de3d3c 100644
--- a/doCheckout.go
+++ b/doCheckout.go
@@ -1,66 +1,11 @@
package main
import (
- "time"
-
- "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
-func doGitPull() {
- allerr := me.found.RillGitPull(40, 5)
-
- all := me.found.SortByFullPath()
- for all.Scan() {
- repo := all.Next()
- result := allerr[repo]
- if result.Error == gitpb.ErrorGitPullOnDirty {
- log.Info("skip git pull. repo is dirty", repo.GetGoPath())
- continue
- }
- if result.Error == gitpb.ErrorGitPullOnLocal {
- log.Info("skip git pull. local branch ", repo.GetGoPath())
- continue
- }
- if result.Exit == 0 {
- continue
- }
-
- log.Info("git pull error:", repo.GetGoPath(), result.Error)
- log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
- }
-
-}
-
-func doCheckDirtyAndConfigSave() {
- var count int
- now := time.Now()
- // log.Info("before findAll()")
- all := me.found.SortByFullPath()
- for all.Scan() {
- repo := all.Next()
- // log.Info("before isDirty()")
- dirty := repo.IsDirty()
- if repo.CheckDirty() {
- count += 1
- if me.found.AppendByGoPath(repo) {
- log.Info("doCheckDirtyAndConfigSave() repo already existed", repo.GetGoPath())
- }
- if !dirty {
- configSave = true
- }
- } else {
- if dirty {
- configSave = true
- }
- }
- }
- log.Printf("dirty check (%d repos) took:%s\n", count, shell.FormatDuration(time.Since(now)))
- me.forge.SetConfigSave(configSave)
-}
-
func IsEverythingOnDevel() bool {
me.found = new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
diff --git a/doDirty.go b/doDirty.go
new file mode 100644
index 0000000..e7c5b8b
--- /dev/null
+++ b/doDirty.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "time"
+
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func doDirty() {
+ findAll() // select all the repos
+ doCheckDirtyAndConfigSave()
+ me.found = new(gitpb.Repos)
+ findDirty()
+ me.forge.PrintHumanTableDirty(me.found)
+}
+
+func doCheckDirtyAndConfigSave() {
+ var count int
+ now := time.Now()
+ // log.Info("before findAll()")
+ all := me.found.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ // log.Info("before isDirty()")
+ dirty := repo.IsDirty()
+ if repo.CheckDirty() {
+ count += 1
+ if me.found.AppendByGoPath(repo) {
+ log.Info("doCheckDirtyAndConfigSave() repo already existed", repo.GetGoPath())
+ }
+ if !dirty {
+ configSave = true
+ }
+ } else {
+ if dirty {
+ configSave = true
+ }
+ }
+ }
+ log.Printf("dirty check (%d repos) took:%s\n", count, shell.FormatDuration(time.Since(now)))
+ me.forge.SetConfigSave(configSave)
+}
diff --git a/doExamine.go b/doExamine.go
new file mode 100644
index 0000000..7d8794a
--- /dev/null
+++ b/doExamine.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "time"
+
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func doExamine() bool {
+ me.found = new(gitpb.Repos)
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ if tag := repo.ExamineBranches(); tag != nil {
+ me.found.AppendByGoPath(repo)
+ ctime := tag.Creatordate.AsTime()
+ dur := time.Since(ctime)
+ log.Printf("UNKNOWN BRANCH %-50s %s %4s %s\n", repo.GetFullPath(), tag.Hash, shell.FormatDuration(dur), tag.Refname)
+ }
+ }
+ if len(me.found.Repos) == 0 {
+ return true
+ }
+ me.forge.PrintHumanTableDirty(me.found)
+ return false
+}
diff --git a/doPull.go b/doPull.go
new file mode 100644
index 0000000..44a1b82
--- /dev/null
+++ b/doPull.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func doGitPull() {
+ allerr := me.found.RillGitPull(40, 5)
+
+ all := me.found.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ result := allerr[repo]
+ if result.Error == gitpb.ErrorGitPullOnDirty {
+ log.Info("skip git pull. repo is dirty", repo.GetGoPath())
+ continue
+ }
+ if result.Error == gitpb.ErrorGitPullOnLocal {
+ log.Info("skip git pull. local branch ", repo.GetGoPath())
+ continue
+ }
+ if result.Exit == 0 {
+ continue
+ }
+
+ log.Info("git pull error:", repo.GetGoPath(), result.Error)
+ log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
+ }
+
+}
diff --git a/main.go b/main.go
index 41151b0..4312d33 100644
--- a/main.go
+++ b/main.go
@@ -122,11 +122,12 @@ func main() {
}
if argv.Dirty != nil {
- findAll() // select all the repos
- doCheckDirtyAndConfigSave()
- me.found = new(gitpb.Repos)
- findDirty()
- me.forge.PrintHumanTableDirty(me.found)
+ doDirty()
+ okExit("")
+ }
+
+ if argv.Examine != nil {
+ doExamine()
okExit("")
}