summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-05 02:01:15 -0600
committerJeff Carr <[email protected]>2025-01-05 02:01:15 -0600
commit026e0cde90ed89a51b97d163ba63339439cbe999 (patch)
treebbfc62800fa58286f706cd630be235a1c5e800d1
parent18ee541f89be2e9f9a91c54873da87885e8ffdf5 (diff)
button to dump last patch info
-rw-r--r--applyPatch.go23
-rw-r--r--send.go29
-rw-r--r--windowPatches.go11
3 files changed, 49 insertions, 14 deletions
diff --git a/applyPatch.go b/applyPatch.go
index a0ddbab..d4eec08 100644
--- a/applyPatch.go
+++ b/applyPatch.go
@@ -11,6 +11,21 @@ import (
"go.wit.com/log"
)
+func dumpPatchset(pset *forgepb.Patchs) error {
+ log.Info("applyPatches() NAME", pset.Name)
+ log.Info("applyPatches() COMMENT", pset.Comment)
+ log.Info("applyPatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName())
+ log.Info("applyPatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
+ all := pset.SortByFilename()
+ for all.Scan() {
+ p := all.Next()
+ // log.Info("pset filename FILENAME IS REAL?", p.Filename, pset.Name, pset.Comment)
+ // basepath, filename := filepath.Split(p.Filename)
+ log.Info("pset p.Filename", p.Filename)
+ }
+ return nil
+}
+
func applyPatches(pset *forgepb.Patchs) error {
var everythingworked bool = true
tmpdir, err := os.MkdirTemp("", "forge")
@@ -77,11 +92,3 @@ func handleBytes(bytes []byte) (*forgepb.Patchs, error) {
}
return pset, nil
}
-
-func doit(bytes []byte) error {
- pset, err := handleBytes(bytes)
- if err != nil {
- return err
- }
- return applyPatches(pset)
-}
diff --git a/send.go b/send.go
index 650b78f..c6c9665 100644
--- a/send.go
+++ b/send.go
@@ -55,6 +55,25 @@ func listPatches() error {
return nil
}
+func lastPatch() string {
+ var url string
+ url = me.urlbase + "/patchsetlist"
+ body, err := httpPost(url, nil)
+ if err != nil {
+ log.Info("httpPost() failed:", err)
+ return ""
+ }
+
+ var last string
+ test := strings.TrimSpace(string(body))
+ for _, line := range strings.Split(test, "\n") {
+ log.Info("patchset:", line)
+ last = strings.TrimSpace(line)
+ }
+ parts := strings.Fields(last)
+ return parts[0]
+}
+
func doRegister(newurl string) error {
var url string
url = me.urlbase + "/register?url=" + newurl
@@ -72,13 +91,13 @@ func doRegister(newurl string) error {
return nil
}
-func getPatch(pbfile string) error {
+func getPatch(pbfile string) (*forgepb.Patchs, 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
+ return nil, err
}
log.Info("getPatch() len(body)", len(body))
var pset *forgepb.Patchs
@@ -86,15 +105,13 @@ func getPatch(pbfile string) error {
err = pset.Unmarshal(body)
if err != nil {
log.Info("Unmarshal failed", err)
- return err
+ return nil, err
}
filename := filepath.Join("/tmp", pbfile)
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(body)
f.Close()
-
- doit(body)
- return nil
+ return pset, nil
}
func sendDevelDiff(name string) error {
diff --git a/windowPatches.go b/windowPatches.go
index f0e5d6d..e153553 100644
--- a/windowPatches.go
+++ b/windowPatches.go
@@ -163,9 +163,20 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
log.Info("sent patch set ok")
}
})
+
s.grid.NewButton("Show Patchsets", func() {
listPatches()
})
+
+ s.grid.NewButton("Get Latest Patchset", func() {
+ lastp := lastPatch()
+ pset, err := getPatch(lastp)
+ if err != nil {
+ return
+ }
+ dumpPatchset(pset)
+ })
+
s.grid.NewButton("Show Repos", func() {
s.Update()
if me.repos.Hidden() {