From 30dcc8af9f35ed988b79d39121801d3a27a036c2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 3 Sep 2025 05:50:18 -0500 Subject: [PATCH] working on patch handling --- Makefile | 2 +- all-patches.pb | 2 ++ argv.go | 12 ++++++++---- argvAutoshell.go | 2 +- doGui.go | 3 ++- doPatch.go | 39 +++++++++++++++------------------------ windowPatchsets.go | 12 ++++++++---- 7 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 all-patches.pb diff --git a/Makefile b/Makefile index 87462a4..d0b028a 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ pull: install # cloudflare blocks POST due to captcha checks / human detection? # POST must be direct socket. probably for the best anyway submit: - FORGE_URL="https://forge.grid.wit.com/" forge patch --submit "forge auto commit" + FORGE_URL="https://forge.grid.wit.com/" forge patch submit "forge auto commit" # forge patch --submit "forge auto commit" commit: diff --git a/all-patches.pb b/all-patches.pb new file mode 100644 index 0000000..7ac8ae7 --- /dev/null +++ b/all-patches.pb @@ -0,0 +1,2 @@ + +$be926ad9-f07f-484c-adf2-d96eeabf3079'v0.0.45 go.wit.com/lib/protobuf/forgepb \ No newline at end of file diff --git a/argv.go b/argv.go index 6baab59..e1f855d 100644 --- a/argv.go +++ b/argv.go @@ -62,10 +62,14 @@ type CleanDevelCmd struct { } 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 string `arg:"--submit" help:"submit your commits"` + 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"` +} + +type SubmitCmd struct { + Match string `arg:"positional"` } type PullCmd struct { diff --git a/argvAutoshell.go b/argvAutoshell.go index afceaa0..75e53bb 100644 --- a/argvAutoshell.go +++ b/argvAutoshell.go @@ -52,7 +52,7 @@ func (args) doBashAuto() { case "--find": fmt.Println("foo bar") case "patch": - fmt.Println("get list --submit show") + fmt.Println("get list submit show") case "user": fmt.Println("--force") case "devel": diff --git a/doGui.go b/doGui.go index ec28b2a..630e059 100644 --- a/doGui.go +++ b/doGui.go @@ -146,7 +146,8 @@ func drawWindow(win *gadgets.GenericWindow) { patchesWin.Toggle() return } - loadUpstreamPatchsets() + me.forge.GetPatches() + // loadUpstreamPatchsets() if me.psets == nil { log.Info("failed to download current patchsets") return diff --git a/doPatch.go b/doPatch.go index d025de4..ee3631d 100644 --- a/doPatch.go +++ b/doPatch.go @@ -13,8 +13,15 @@ import ( ) func doPatch() error { - if argv.Patch.Submit != "" { - _, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit) + 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) + } + } + + if argv.Patch.Submit != nil { + _, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit.Match) if err != nil { return err } @@ -22,7 +29,12 @@ func doPatch() error { } if argv.Patch.Get != nil { - return doPatchGet() + if err := me.forge.GetPatches(); err != nil { + log.Info("Get Patchsets Failed", err) + return err + } + me.forge.Patchsets.PrintTable() + return nil } if argv.Patch.List != nil { @@ -156,24 +168,3 @@ func IsValidPatch(p *forgepb.Patch) bool { } return true } - -func doPatchGet() error { - psets, err := me.forge.GetPatchesets() - if err != nil { - log.Info("Get Patchsets failed", err) - return err - } - log.Info("Got Patchsets ok", psets.Uuid) - - log.Info("got psets len", len(psets.Patchsets)) - all := psets.SortByName() - for all.Scan() { - pset := all.Next() - // log.Info("pset name =", pset.Name) - dumpPatchset(pset) - } - - log.Info("FIXME: can't save these yet. must merge with on disk psets here") - // savePatchsets() - return nil -} diff --git a/windowPatchsets.go b/windowPatchsets.go index 4b102b2..29a2929 100644 --- a/windowPatchsets.go +++ b/windowPatchsets.go @@ -36,6 +36,7 @@ func (w *stdPatchsetTableWin) Toggle() { w.win.Toggle() } +/* func loadUpstreamPatchsets() { psets, err := me.forge.GetPatchesets() if err != nil { @@ -66,6 +67,7 @@ func loadUpstreamPatchsets() { savePatchsets() } } +*/ func makePatchsetsWin() *stdPatchsetTableWin { dwin := new(stdPatchsetTableWin) @@ -84,10 +86,12 @@ func makePatchsetsWin() *stdPatchsetTableWin { dwin.doPatchsetsTable(me.psets) }) - grid.NewButton("upstream", func() { - loadUpstreamPatchsets() - dwin.doPatchsetsTable(me.psets) - }) + /* + grid.NewButton("upstream", func() { + loadUpstreamPatchsets() + dwin.doPatchsetsTable(me.psets) + }) + */ grid.NewButton("save", func() { if me.psets == nil {