summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go4
-rw-r--r--doGui.go11
-rw-r--r--doPatch.go65
-rw-r--r--structs.go14
4 files changed, 37 insertions, 57 deletions
diff --git a/argv.go b/argv.go
index e1a1663..2ac11ad 100644
--- a/argv.go
+++ b/argv.go
@@ -107,9 +107,7 @@ type CleanDevelCmd struct {
}
type PatchCmd struct {
- Get bool `arg:"--get" help:"get the new patchsets"`
- Show bool `arg:"--show" help:"show all the current patches"`
- Fix bool `arg:"--fix" help:"attempt to apply any new patches"`
+ Apply bool `arg:"--apply" help:"attempt to apply any new patches"`
Submit bool `arg:"--resubmit" help:"resubmit your git commits"`
}
diff --git a/doGui.go b/doGui.go
index e83b8b8..384c1f6 100644
--- a/doGui.go
+++ b/doGui.go
@@ -13,7 +13,6 @@ import (
"go.wit.com/gui"
"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"
)
@@ -90,11 +89,11 @@ func doGui() {
patchButton.SetLabel("not safe yet")
return
}
- curpatches := forgepb.NewPatches()
- curpatches.Filename = "/tmp/curpatches.pb"
- curpatches.Load()
- curpatches.Save()
- patchesWin = makePatchesWin(curpatches)
+ if me.curpatches == nil {
+ log.Info("me.curpatches == nil")
+ return
+ }
+ patchesWin = makePatchesWin(me.curpatches)
})
var pubWin *gadgets.GenericWindow
diff --git a/doPatch.go b/doPatch.go
index 111cf8c..8e2afbc 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -36,18 +36,23 @@ func isPatchingSafe() bool {
}
func doPatch() (string, error) {
- if argv.Patch.Submit {
- return doPatchSubmit()
+ // var changed bool
+ me.curpatches = forgepb.NewPatches()
+ me.curpatches.Filename = "/tmp/curpatches.pb"
+ if err := me.curpatches.Load(); err != nil {
+ me.curpatches.Save()
+ me.curpatches.Save()
+ log.Info(err)
+ panic("no file")
+ // return
+ // // THIS IS NEEDED? NOTSURE
+ me.curpatches = forgepb.NewPatches()
+ me.curpatches.Filename = "/tmp/curpatches.pb"
+ me.curpatches.Save()
}
- if argv.Patch.Show {
- curpatches := forgepb.NewPatches()
- curpatches.Filename = "/tmp/curpatches.pb"
- if err := curpatches.Load(); err != nil {
- return "fix curpatches.pb", err
- }
- footer := curpatches.PrintTable()
- return "all current patches: " + footer, nil
+ if argv.Patch.Submit {
+ return doPatchSubmit()
}
psets := forgepb.NewSets()
@@ -85,15 +90,8 @@ func doPatchSubmit() (string, error) {
}
func doPatchProcess() (string, error) {
- curpatches := forgepb.NewPatches()
- curpatches.Filename = "/tmp/curpatches.pb"
- if err := curpatches.Load(); err != nil {
- return "fix curpatches.pb", err
- }
- // footer := curpatches.PrintTable()
- // log.Info("START curpatches:", footer)
var needfix int
- for patch := range curpatches.IterAll() {
+ for patch := range me.curpatches.IterAll() {
repo := me.forge.Repos.FindByNamespace(patch.Namespace)
if repo == nil {
// log.Info("no namespace", patch.PatchId, patch.Namespace, patch.Comment)
@@ -144,7 +142,7 @@ func doPatchProcess() (string, error) {
}
// log.Info(patch.PatchId, newId, repo.Namespace, "new patch", patch.Comment)
patch.State = "new patch"
- if !argv.Fix {
+ if !argv.Patch.Apply {
needfix += 1
} else {
log.Info(string(patch.Data))
@@ -184,7 +182,7 @@ func doPatchProcess() (string, error) {
}
// NOW, FINALLY, AFTER A LOT OF WORK, THE FUN PART
newpatches := forgepb.NewPatches()
- for p := range curpatches.IterAll() {
+ for p := range me.curpatches.IterAll() {
if p.NewHash == "author" {
// this is your patch
continue
@@ -199,15 +197,15 @@ func doPatchProcess() (string, error) {
}
newpatches.Clone(p)
}
- curpatches.Save()
+ me.curpatches.Save()
if newpatches.Len() == 0 {
- s := log.Sprintf("All (%d) current patches are appled. You are completely up to date!", curpatches.Len())
+ s := log.Sprintf("All (%d) current patches are appled. You are completely up to date!", me.curpatches.Len())
return s, nil
}
footer := newpatches.PrintTable()
log.Info("BRAND NEW PATCHES:", footer)
var s string
- s = log.Sprintf("There are %d new patches. Use --fix to apply them", needfix)
+ s = log.Sprintf("There are %d new patches. Use --apply to apply them", needfix)
return s, nil
}
@@ -291,21 +289,6 @@ func applyPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) {
}
func doPatchGet(newpb *forgepb.Sets) (string, error) {
- // var changed bool
- curpatches := forgepb.NewPatches()
- curpatches.Filename = "/tmp/curpatches.pb"
- if err := curpatches.Load(); err != nil {
- curpatches.Save()
- curpatches.Save()
- log.Info(err)
- panic("no file")
- // return
- // // THIS IS NEEDED? NOTSURE
- curpatches = forgepb.NewPatches()
- curpatches.Filename = "/tmp/curpatches.pb"
- curpatches.Save()
- }
-
newpatches := forgepb.NewPatches()
for pset := range newpb.IterAll() {
if pset.Patches.Len() == 0 {
@@ -329,22 +312,22 @@ func doPatchGet(newpb *forgepb.Sets) (string, error) {
log.Info("ERROR: patchid's didn't match", patchid, patch.PatchId)
continue
}
- found := curpatches.FindByPatchId(patch.PatchId)
+ found := me.curpatches.FindByPatchId(patch.PatchId)
if found != nil {
// already have this patch
continue
}
// gitpb.FindPatchIdFromGitAmBroken(patch.Data) // doesn't os.Exec()
log.Info("adding new patch", patch.CommitHash, patch.PatchId, patch.Filename)
- curpatches.AppendByPatchId(patch)
+ me.curpatches.AppendByPatchId(patch)
newpatches.AppendByPatchId(patch)
}
}
- curpatches.Save()
if newpatches.Len() == 0 {
return "", nil
}
footer := newpatches.PrintTable()
+ me.curpatches.Save()
s := log.Sprintf("got %d new patches. %s", newpatches.Len(), footer)
return s, nil
}
diff --git a/structs.go b/structs.go
index fcdc07f..5dceade 100644
--- a/structs.go
+++ b/structs.go
@@ -27,13 +27,13 @@ func myServer() string {
// this app's variables
type mainType struct {
- // pp *arg.Parser // for parsing the command line args. Yay to alexflint!
- sh *prep.Auto // shell autocomplete
- forge *forgepb.Forge // for holding the forge protobuf files
- myGui *prep.GuiPrep // for initializing the GUI toolkits
- foundPaths []string // stores gopaths to act on (when doing go-clone)
- configSave bool // if the config file should be saved after finishing
- urlbase string // base URL
+ sh *prep.Auto // shell autocomplete
+ forge *forgepb.Forge // for holding the forge protobuf files
+ myGui *prep.GuiPrep // for initializing the GUI toolkits
+ foundPaths []string // stores gopaths to act on (when doing go-clone)
+ configSave bool // if the config file should be saved after finishing
+ urlbase string // base URL
+ curpatches *forgepb.Patches // current patches not upstream
mainWindow *gadgets.BasicWindow
mainbox *gui.Node // the main box. enable/disable this