summaryrefslogtreecommitdiff
path: root/send.go
diff options
context:
space:
mode:
Diffstat (limited to 'send.go')
-rw-r--r--send.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/send.go b/send.go
index 745426a..6067baf 100644
--- a/send.go
+++ b/send.go
@@ -96,6 +96,8 @@ func doRegister(newurl string) error {
return nil
}
+// gets the patch
+// todo: move to forgepb
func getPatch(pbfile string) (*forgepb.Patchset, error) {
url := me.urlbase + "/patchsetget?filename=" + pbfile
log.Info("getPatch() url", url)
@@ -112,6 +114,25 @@ func getPatch(pbfile string) (*forgepb.Patchset, error) {
log.Info("Unmarshal failed", err)
return nil, err
}
+ return pset, nil
+}
+
+func savePatch(pbfile string) (*forgepb.Patchset, error) {
+ url := me.urlbase + "/patchsetget?filename=" + pbfile
+ log.Info("getPatch() url", url)
+ body, err := me.forge.HttpPost(url, nil)
+ if err != nil {
+ log.Info("httpPost() failed:", err)
+ return nil, err
+ }
+ log.Info("getPatch() len(body)", len(body))
+ var pset *forgepb.Patchset
+ pset = new(forgepb.Patchset)
+ err = pset.Unmarshal(body)
+ if err != nil {
+ log.Info("Unmarshal failed", 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)