button to dump last patch info

This commit is contained in:
Jeff Carr 2025-01-05 02:01:15 -06:00
parent 18ee541f89
commit 026e0cde90
3 changed files with 49 additions and 14 deletions

View File

@ -11,6 +11,21 @@ import (
"go.wit.com/log" "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 { func applyPatches(pset *forgepb.Patchs) error {
var everythingworked bool = true var everythingworked bool = true
tmpdir, err := os.MkdirTemp("", "forge") tmpdir, err := os.MkdirTemp("", "forge")
@ -77,11 +92,3 @@ func handleBytes(bytes []byte) (*forgepb.Patchs, error) {
} }
return pset, nil return pset, nil
} }
func doit(bytes []byte) error {
pset, err := handleBytes(bytes)
if err != nil {
return err
}
return applyPatches(pset)
}

29
send.go
View File

@ -55,6 +55,25 @@ func listPatches() error {
return nil 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 { func doRegister(newurl string) error {
var url string var url string
url = me.urlbase + "/register?url=" + newurl url = me.urlbase + "/register?url=" + newurl
@ -72,13 +91,13 @@ func doRegister(newurl string) error {
return nil return nil
} }
func getPatch(pbfile string) error { func getPatch(pbfile string) (*forgepb.Patchs, error) {
url := me.urlbase + "/patchsetget?filename=" + pbfile url := me.urlbase + "/patchsetget?filename=" + pbfile
log.Info("getPatch() url", url) log.Info("getPatch() url", url)
body, err := httpPost(url, nil) body, err := httpPost(url, nil)
if err != nil { if err != nil {
log.Info("httpPost() failed:", err) log.Info("httpPost() failed:", err)
return err return nil, err
} }
log.Info("getPatch() len(body)", len(body)) log.Info("getPatch() len(body)", len(body))
var pset *forgepb.Patchs var pset *forgepb.Patchs
@ -86,15 +105,13 @@ func getPatch(pbfile string) error {
err = pset.Unmarshal(body) err = pset.Unmarshal(body)
if err != nil { if err != nil {
log.Info("Unmarshal failed", err) log.Info("Unmarshal failed", err)
return err return nil, err
} }
filename := filepath.Join("/tmp", pbfile) filename := filepath.Join("/tmp", pbfile)
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(body) f.Write(body)
f.Close() f.Close()
return pset, nil
doit(body)
return nil
} }
func sendDevelDiff(name string) error { func sendDevelDiff(name string) error {

View File

@ -163,9 +163,20 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
log.Info("sent patch set ok") log.Info("sent patch set ok")
} }
}) })
s.grid.NewButton("Show Patchsets", func() { s.grid.NewButton("Show Patchsets", func() {
listPatches() 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.grid.NewButton("Show Repos", func() {
s.Update() s.Update()
if me.repos.Hidden() { if me.repos.Hidden() {