http post a patch set
This commit is contained in:
parent
a11c4f46bd
commit
268e05f108
3
Makefile
3
Makefile
|
@ -60,3 +60,6 @@ gui: install
|
||||||
|
|
||||||
patches: install
|
patches: install
|
||||||
forge --do-patches
|
forge --do-patches
|
||||||
|
|
||||||
|
patches-localhost: install
|
||||||
|
forge --do-patches --url "http://localhost:2233/"
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
WIT.COM Inc. as part of the go.wit.com project.
|
||||||
|
|
||||||
|
WIT.COM Inc. hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation on go.wit.com, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by WIT.COM Inc. and acquired in
|
||||||
|
the future, licensable by WIT.COM Inc. that are necessarily infringed by this
|
||||||
|
implementation on go.wit.com. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation on go.wit.com or any code incorporated within this
|
||||||
|
implementation on go.wit.com constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation on go.wit.com
|
||||||
|
shall terminate as of the date such litigation is filed.
|
1
argv.go
1
argv.go
|
@ -26,6 +26,7 @@ type args struct {
|
||||||
DoGui bool `arg:"--do-gui" help:"test the gui"`
|
DoGui bool `arg:"--do-gui" help:"test the gui"`
|
||||||
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
||||||
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
|
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
|
||||||
|
URL string `arg:"--url" default:"http://go.wit.com/" help:"base url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (args) Version() string {
|
func (args) Version() string {
|
||||||
|
|
35
main.go
35
main.go
|
@ -4,6 +4,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
@ -21,6 +22,8 @@ var configSave bool
|
||||||
func main() {
|
func main() {
|
||||||
me = new(mainType)
|
me = new(mainType)
|
||||||
me.pp = arg.MustParse(&argv)
|
me.pp = arg.MustParse(&argv)
|
||||||
|
me.urlbase = argv.URL
|
||||||
|
me.urlbase = strings.Trim(me.urlbase, "/") // track down why trailing '/' makes http POST not work
|
||||||
|
|
||||||
// load the ~/.config/forge/ config
|
// load the ~/.config/forge/ config
|
||||||
me.forge = forgepb.Init()
|
me.forge = forgepb.Init()
|
||||||
|
@ -87,35 +90,3 @@ func main() {
|
||||||
doCobol()
|
doCobol()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendDevelDiff() {
|
|
||||||
pset, err := me.forge.MakeDevelPatchSet()
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
all := pset.SortByFilename()
|
|
||||||
for all.Scan() {
|
|
||||||
p := all.Next()
|
|
||||||
log.Info("read in patch:", p.Filename)
|
|
||||||
}
|
|
||||||
err = me.forge.SendPatchSet(pset)
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendMasterDiff() {
|
|
||||||
pset, err := me.forge.MakeMasterPatchSet()
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
all := pset.SortByFilename()
|
|
||||||
for all.Scan() {
|
|
||||||
p := all.Next()
|
|
||||||
log.Info("read in patch:", p.Filename)
|
|
||||||
}
|
|
||||||
err = me.forge.SendPatchSet(pset)
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func httpPost(url string, data []byte) ([]byte, error) {
|
||||||
|
var err error
|
||||||
|
var req *http.Request
|
||||||
|
|
||||||
|
// data := []byte("some junk")
|
||||||
|
// url := "https://go.wit.com/register/"
|
||||||
|
|
||||||
|
req, err = http.NewRequest(http.MethodPost, url, bytes.NewBuffer(data))
|
||||||
|
log.Info("httpPost() with len", len(data), "url", url)
|
||||||
|
|
||||||
|
usr, _ := user.Current()
|
||||||
|
req.Header.Set("author", usr.Username)
|
||||||
|
hostname, _ := os.Hostname()
|
||||||
|
req.Header.Set("hostname", hostname)
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return []byte("client.Do(req) error"), err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
log.Info("httpPost() with len", len(data))
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return body, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// test := strings.TrimSpace(string(body))
|
||||||
|
// log.Info("go.wit.com returned body:", test)
|
||||||
|
// if test == "OK" {
|
||||||
|
// return body, nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
return body, nil
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright 2024 WIT.COM Inc Licensed GPL 3.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func sendPatches(pset *forgepb.Patchs) error {
|
||||||
|
var url string
|
||||||
|
url = me.urlbase + "/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 := httpPost(url, msg)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("httpPost() failed:", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
test := strings.TrimSpace(string(body))
|
||||||
|
// log.Info("virtigo returned body:", test)
|
||||||
|
for _, line := range strings.Split(test, "\n") {
|
||||||
|
log.Info("got back:", line)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendDevelDiff() {
|
||||||
|
pset, err := me.forge.MakeDevelPatchSet()
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
if err := sendPatches(pset); err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
all := pset.SortByFilename()
|
||||||
|
for all.Scan() {
|
||||||
|
p := all.Next()
|
||||||
|
log.Info("read in patch:", p.Filename)
|
||||||
|
}
|
||||||
|
err = me.forge.SendPatchSet(pset)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendMasterDiff() {
|
||||||
|
pset, err := me.forge.MakeMasterPatchSet()
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
all := pset.SortByFilename()
|
||||||
|
for all.Scan() {
|
||||||
|
p := all.Next()
|
||||||
|
log.Info("read in patch:", p.Filename)
|
||||||
|
}
|
||||||
|
err = me.forge.SendPatchSet(pset)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ type mainType struct {
|
||||||
found *gitpb.Repos // stores the list of repos to process things on
|
found *gitpb.Repos // stores the list of repos to process things on
|
||||||
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
||||||
configSave bool // if the config file should be saved after finishing
|
configSave bool // if the config file should be saved after finishing
|
||||||
|
urlbase string // base URL
|
||||||
|
|
||||||
// our view of the repositories
|
// our view of the repositories
|
||||||
repos *repoWindow
|
repos *repoWindow
|
||||||
|
|
Loading…
Reference in New Issue