From be3841578cb466f02bbc4ea1e13e024b5a77e85d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 14 Dec 2024 14:09:15 -0600 Subject: [PATCH] list patches and get a patch set works --- Makefile | 3 +++ argv.go | 1 + main.go | 5 +++++ send.go | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/Makefile b/Makefile index 6e2872f..440a160 100644 --- a/Makefile +++ b/Makefile @@ -63,3 +63,6 @@ patches: install patches-localhost: install forge --do-patches --url "http://localhost:2233/" + +patches-list: install + forge --list-patches --url "http://localhost:2233/" diff --git a/argv.go b/argv.go index 2ca704c..d731903 100644 --- a/argv.go +++ b/argv.go @@ -23,6 +23,7 @@ type args struct { DoInstall bool `arg:"--do-install" help:"try to install every binary package"` DoRedoGoMod bool `arg:"--do-RedoGoMod" help:"remake all the go.sum and go.mod files"` DoPatchSet bool `arg:"--do-patches" help:"make patch set"` + ListPatchSet bool `arg:"--list-patches" help:"make patch set"` DoGui bool `arg:"--do-gui" help:"test the gui"` DryRun bool `arg:"--dry-run" help:"show what would be run"` Fix bool `arg:"--fix" help:"fix config, save config & exit"` diff --git a/main.go b/main.go index 5a9c673..0ebe1bc 100644 --- a/main.go +++ b/main.go @@ -81,6 +81,11 @@ func main() { okExit("patches") } + if argv.ListPatchSet { + listPatches() + okExit("patches") + } + // do the gui at the very end if argv.DoGui { doGui() diff --git a/send.go b/send.go index 4a1046f..b04b503 100644 --- a/send.go +++ b/send.go @@ -32,6 +32,37 @@ func sendPatches(pset *forgepb.Patchs) error { return nil } +func listPatches() error { + var url string + url = me.urlbase + "/patchsetlist" + body, err := httpPost(url, nil) + if err != nil { + log.Info("httpPost() failed:", err) + return err + } + + var last string + test := strings.TrimSpace(string(body)) + for _, line := range strings.Split(test, "\n") { + log.Info("patchset:", line) + last = strings.TrimSpace(line) + } + getPatch(last) + return nil +} + +func getPatch(pbfile string) error { + url := me.urlbase + "/patchsetget?filename=" + pbfile + log.Info("getPatch() url", url) + body, err := httpPost(url, nil) + if err != nil { + log.Info("httpPost() failed:", err) + return err + } + log.Info("getPatch() len(body)", len(body)) + return nil +} + func sendDevelDiff() { pset, err := me.forge.MakeDevelPatchSet() if err != nil {