summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--argv.go3
-rw-r--r--argvAutoshell.go2
-rw-r--r--doGui.go43
-rw-r--r--doNormal.go2
-rw-r--r--doPatch.go17
-rw-r--r--helperPatches.go17
-rw-r--r--windowPatches.go10
8 files changed, 67 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index be4c8c2..16e9324 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
# make andlabs # try the andlabs gui plugin (uses GTK)
default: verbose install
- forge patch list
+ forge patch
vet:
@GO111MODULE=off go vet
diff --git a/argv.go b/argv.go
index 7d92c80..2dfbc42 100644
--- a/argv.go
+++ b/argv.go
@@ -66,7 +66,8 @@ type PatchCmd struct {
List *EmptyCmd `arg:"subcommand:list" help:"your downloaded patchsets"`
Get *EmptyCmd `arg:"subcommand:get" help:"get the new patchsets"`
Show *EmptyCmd `arg:"subcommand:show" help:"your pending commits to your code"`
- Submit *SubmitCmd `arg:"subcommand:submit" help:"submit your commits"`
+ Submit *SubmitCmd `arg:"subcommand:submit" help:"submit your commits"`
+ Repos *SubmitCmd `arg:"subcommand:repos" help:"show repos with patches"`
}
type SubmitCmd struct {
diff --git a/argvAutoshell.go b/argvAutoshell.go
index a255214..899d2e2 100644
--- a/argvAutoshell.go
+++ b/argvAutoshell.go
@@ -46,7 +46,7 @@ func (args) doBashAuto() {
case "pull":
fmt.Println("dirty clean list patches --force")
case "patch":
- fmt.Println("check get list submit show")
+ fmt.Println("check get list repos submit show")
case "user":
fmt.Println("--force")
case "devel":
diff --git a/doGui.go b/doGui.go
index 579903f..be3200a 100644
--- a/doGui.go
+++ b/doGui.go
@@ -14,6 +14,7 @@ import (
"go.wit.com/lib/fhelp"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -168,28 +169,32 @@ func drawWindow(win *gadgets.GenericWindow) {
patchesWin.Toggle()
return
}
- // me.forge.GetPatches()
- // loadUpstreamPatchsets()
- /*
- if me.psets == nil {
- log.Info("failed to download current patchsets")
- return
+ // load the current patches protobuf file
+ if err := me.forge.LoadPatchsets(); err != nil {
+ log.Info("patches failed to open", err)
+ if err := me.forge.SavePatchsets(); err != nil {
+ log.Warn("savePatchsets() failed", err)
}
- notdone := new(forgepb.Patches)
+ }
+ // patchesWin = makePatchesWin(me.forge.Patchsets)
+ notdone := new(forgepb.Patches)
- all := me.psets.All()
- for all.Scan() {
- pset := all.Next()
- AddNotDonePatches(notdone, pset, false)
- }
+ if me.forge.Patchsets == nil {
+ log.Info("patchsets == nil")
+ return
+ }
+ all := me.forge.Patchsets.All()
+ for all.Scan() {
+ pset := all.Next()
+ AddAllPatches(notdone, pset, false)
+ // AddNotDonePatches(notdone, pset, false)
+ }
- for patch := range notdone.IterAll() {
- comment := cleanSubject(patch.Comment)
- log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
- }
- // savePatchsets()
- patchesWin = makePatchesWin(notdone)
- */
+ for patch := range notdone.IterAll() {
+ comment := cleanSubject(patch.Comment)
+ log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
+ }
+ patchesWin = makePatchesWin(notdone)
})
var pubWin *gadgets.GenericWindow
diff --git a/doNormal.go b/doNormal.go
index dc9588f..e887538 100644
--- a/doNormal.go
+++ b/doNormal.go
@@ -13,7 +13,7 @@ import (
)
func doNormal() bool {
- me.forge.CheckDirty()
+ me.forge.CheckDirtyQuiet()
var count int
stats := me.forge.RillRepos(checkNormalRepoState)
diff --git a/doPatch.go b/doPatch.go
index 52a90f1..1abf5b3 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -56,18 +56,27 @@ func doPatch() error {
return nil
}
+ if argv.Patch.Repos != nil {
+ dumpDirtyRepos()
+ }
+
+ // if nothing, show patches & dirty repos
+ me.forge.Patchsets.PrintTable()
+ dumpDirtyRepos()
+ return nil
+}
+
+func dumpDirtyRepos() {
// always run dirty first
- me.forge.CheckDirty()
+ me.forge.CheckDirtyQuiet()
// if no option is given to patch, list out the
// repos that have patches ready in them
found := findReposWithPatches()
if found.Len() == 0 {
- log.Info("you currently have no patches in your user branches")
- return nil
+ log.Info("you currently have no repos with patches")
}
me.forge.PrintHumanTable(found)
- return nil
}
// returns bad if patches can not be applied
diff --git a/helperPatches.go b/helperPatches.go
index 3450452..ba0f37f 100644
--- a/helperPatches.go
+++ b/helperPatches.go
@@ -178,7 +178,6 @@ func setNewCommitHash(p *forgepb.Patchset) bool {
return done
}
-/*
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
for patch := range pset.Patches.IterAll() {
comment := cleanSubject(patch.Comment)
@@ -222,4 +221,18 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bo
notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
}
}
-*/
+
+func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
+ for patch := range pset.Patches.IterAll() {
+ comment := cleanSubject(patch.Comment)
+
+ if found := notdone.FindByCommitHash(patch.CommitHash); found != nil {
+ log.Info("duplicate commit hash", patch.Namespace, "patch:", patch.NewHash, "commithash:", patch.CommitHash, comment)
+ continue
+ }
+ newhash, _ := findCommitByHash(patch.StartHash, comment)
+
+ log.Info("adding patch:", patch.Namespace, patch.CommitHash, comment, newhash)
+ notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
+ }
+}
diff --git a/windowPatches.go b/windowPatches.go
index f70ea63..ad42076 100644
--- a/windowPatches.go
+++ b/windowPatches.go
@@ -158,6 +158,16 @@ func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
dwin.TB.Custom(f)
}
+// used by the PB table
+func funcApplyPatch(p *forgepb.Patch) string {
+ rn := p.Namespace
+ if repo := me.forge.FindByGoPath(rn); repo == nil {
+ // log.Info("Could not figure out repo path", rn)
+ return ""
+ }
+ return "git am"
+}
+
// define what rows to have in the protobuf table
func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
t := pb.NewTable("PatchesPB")