button to dump last patch info
This commit is contained in:
parent
18ee541f89
commit
026e0cde90
|
@ -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)
|
||||
}
|
||||
|
|
29
send.go
29
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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue