summaryrefslogtreecommitdiff
path: root/patchset.Make.go
diff options
context:
space:
mode:
Diffstat (limited to 'patchset.Make.go')
-rw-r--r--patchset.Make.go42
1 files changed, 41 insertions, 1 deletions
diff --git a/patchset.Make.go b/patchset.Make.go
index 1a7cec6..1a2db2d 100644
--- a/patchset.Make.go
+++ b/patchset.Make.go
@@ -11,8 +11,22 @@ import (
"go.wit.com/log"
)
-func (f *Forge) MakeDevelPatchSet() (*Patchset, error) {
+// creates a patchset
+// works from the user branches against the devel branches
+func (f *Forge) SubmitDevelPatchSet(name string) (*Patchset, error) {
pset := new(Patchset)
+ pset.Name = name
+ if os.Getenv("GIT_AUTHOR_NAME") == "" {
+ return nil, fmt.Errorf("GIT_AUTHOR_NAME not set")
+ } else {
+ pset.GitAuthorName = os.Getenv("GIT_AUTHOR_NAME")
+ }
+ if os.Getenv("GIT_AUTHOR_EMAIL") == "" {
+ return nil, fmt.Errorf("GIT_AUTHOR_EMAIL not set")
+ } else {
+ pset.GitAuthorEmail = os.Getenv("GIT_AUTHOR_EMAIL")
+ }
+
dir, err := os.MkdirTemp("", "forge")
if err != nil {
return nil, err
@@ -39,6 +53,10 @@ func (f *Forge) MakeDevelPatchSet() (*Patchset, error) {
return nil, err
}
}
+
+ if err := f.submitPatchset(pset); err != nil {
+ return nil, err
+ }
return pset, nil
}
@@ -191,3 +209,25 @@ func onlyWalkDirs(pDir string) error {
})
return baderr
}
+
+func (f *Forge) submitPatchset(pset *Patchset) error {
+ var url string
+ url = forgeURL + "patchset"
+ msg, err := pset.Marshal()
+ if err != nil {
+ log.Info("proto.Marshal() failed:", err)
+ return err
+ }
+ log.Info("proto.Marshal() msg len", len(msg))
+ body, err := f.HttpPost(url, msg)
+ if err != nil {
+ log.Info("httpPost() failed:", err)
+ return err
+ }
+
+ test := strings.TrimSpace(string(body))
+ for _, line := range strings.Split(test, "\n") {
+ log.Info("got back:", line)
+ }
+ return nil
+}