summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--globalBuildOptions.go6
-rw-r--r--main.go2
-rw-r--r--structs.go5
-rw-r--r--summaryBox.go117
4 files changed, 120 insertions, 10 deletions
diff --git a/globalBuildOptions.go b/globalBuildOptions.go
index 3c3b6ba..de4d8e8 100644
--- a/globalBuildOptions.go
+++ b/globalBuildOptions.go
@@ -27,9 +27,9 @@ func quickCmd(fullpath string, cmd []string) bool {
var b bool
var output string
-// if me.autoWorkingPwd.String() != fullpath {
-// me.autoWorkingPwd.SetValue(fullpath)
-// }
+ // if me.autoWorkingPwd.String() != fullpath {
+ // me.autoWorkingPwd.SetValue(fullpath)
+ // }
if me.autoDryRun.Checked() {
log.Warn("RUN --dry-run", fullpath, cmd)
diff --git a/main.go b/main.go
index a5a549e..ffd0adf 100644
--- a/main.go
+++ b/main.go
@@ -32,7 +32,7 @@ func main() {
vbox2 := box.NewVerticalBox("BOX2")
globalBuildOptions(vbox2)
- summaryBox(vbox2)
+ me.summary = summaryBox(vbox2)
globalResetOptions(box)
diff --git a/structs.go b/structs.go
index c89698a..b1a8d65 100644
--- a/structs.go
+++ b/structs.go
@@ -67,6 +67,11 @@ type autoType struct {
// delete ~/go/src & ~/go/pkg buttons
deleteGoSrcPkgB *gui.Node
+
+ // displays a summary of all the repos
+ // has total dirty, total read-only
+ // total patches, etc
+ summary *develSummary
}
type repo struct {
diff --git a/summaryBox.go b/summaryBox.go
index 3bf0cd5..17f1a34 100644
--- a/summaryBox.go
+++ b/summaryBox.go
@@ -5,23 +5,48 @@ import (
"fmt"
"os"
"path/filepath"
+ "strconv"
+ "strings"
"go.wit.com/gui"
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/gui/repostatus"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
// "go.wit.com/gui/gadgets"
)
-func summaryBox(box *gui.Node) {
- group1 := box.NewGroup("Repository Summary")
- grid := group1.RawGrid()
+type develSummary struct {
+ grid *gui.Node
+ updateB *gui.Node
+ docsB *gui.Node
- grid.NewButton("Show Repository Window", func() {
- globalDisplaySetRepoState()
+ totalOL *gadgets.OneLiner
+ dirtyOL *gadgets.OneLiner
+ readonlyOL *gadgets.OneLiner
+ totalPatchesOL *gadgets.OneLiner
+
+ allp []*patch
+}
+
+func summaryBox(box *gui.Node) *develSummary {
+ s := new(develSummary)
+ group1 := box.NewGroup("Development Branch Summary")
+ s.grid = group1.RawGrid()
+
+ s.updateB = s.grid.NewButton("Update Stats", func() {
+ // globalDisplaySetRepoState()
// reposwin.Toggle()
+ s.Update()
+ })
+
+ s.updateB = s.grid.NewButton("List Patches", func() {
+ for i, p := range s.allp {
+ log.Info(i, p.ref, p.rs.String())
+ }
})
- grid.NewButton("open docs (localhost:8080)", func() {
+ s.docsB = s.grid.NewButton("open docs (localhost:8080)", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
@@ -54,4 +79,84 @@ func summaryBox(box *gui.Node) {
shell.Run([]string{"ping", "-c", "3", "git.wit.org"})
shell.OpenBrowser("http://localhost:8080")
})
+ s.grid.NextRow()
+
+ s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
+ s.grid.NextRow()
+
+ s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
+ s.grid.NextRow()
+
+ s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
+ s.grid.NextRow()
+
+ s.totalPatchesOL = gadgets.NewOneLiner(s.grid, "total commits")
+ s.grid.NextRow()
+
+ return s
+}
+
+func (s *develSummary) Update() {
+ var total, dirty, readonly int
+ for _, repo := range me.allrepos {
+ total += 1
+ if repo.status.CheckDirty() {
+ dirty += 1
+ }
+ if repo.status.ReadOnly() {
+ readonly += 1
+ }
+ }
+ s.totalOL.SetText(strconv.Itoa(total) + " repos")
+ s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
+ s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
+
+ p, allp := s.GetPatches()
+ if s.allp == nil {
+ s.allp = make([]*patch, 0, 0)
+ s.allp = append(s.allp, allp...)
+ }
+ s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches")
+}
+
+type patch struct {
+ ref string
+ comment string
+ rs *repostatus.RepoStatus
+}
+
+func (s *develSummary) GetPatches() (int, []*patch) {
+ var patchcount int
+ patches := make([]*patch, 0, 0)
+ for _, repo := range me.allrepos {
+ // git log --oneline devel..jcarr
+ userv := repo.status.GetUserVersion()
+ develv := repo.status.GetDevelVersion()
+ usern := repo.status.GetUserBranchName()
+ develn := repo.status.GetDevelBranchName()
+ if userv == develv {
+ // log.Info("skipping unchanged repo", repo.String())
+ } else {
+ // log.Info("repo userv, develv", userv, develv)
+ gitcmd := []string{"git", "log", "--oneline", develn + ".." + usern}
+ // log.Info("Run:", gitcmd)
+ err, output := repo.status.RunCmd(gitcmd)
+ if err == nil {
+ // patches := strings.Split(output, "\n")
+ for _, line := range strings.Split(output, "\n") {
+ parts := strings.Split(line, " ")
+ newp := new(patch)
+ newp.rs = repo.status
+ newp.ref = parts[0]
+ newp.comment = strings.Join(parts[1:], " ")
+ log.Info("patch:", line, newp.rs.String())
+ patchcount += 1
+ patches = append(patches, newp)
+ }
+ } else {
+ log.Info("git failed err=", err)
+ }
+ }
+ }
+ return patchcount, patches
}