move submit patchset to forgepb

This commit is contained in:
Jeff Carr 2025-01-28 22:47:53 -06:00
parent bbf5f79acb
commit 345c1ee9b1
5 changed files with 17 additions and 92 deletions

View File

@ -1,13 +0,0 @@
package main
import (
"go.wit.com/log"
)
func doSubmit(name string) {
if err := sendDevelDiff(name); err != nil {
log.Info("sending patches failed", err)
} else {
log.Info("sent patch set ok")
}
}

View File

@ -150,7 +150,10 @@ func main() {
if argv.Patch != nil { if argv.Patch != nil {
if argv.Patch.Submit != "" { if argv.Patch.Submit != "" {
doSubmit(argv.Patch.Submit) _, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit)
if err != nil {
badExit(err)
}
okExit("") okExit("")
} }

19
send.go
View File

@ -3,7 +3,6 @@
package main package main
import ( import (
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -12,7 +11,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
func sendPatches(pset *forgepb.Patchset) error { func submitPatches(pset *forgepb.Patchset) error {
var url string var url string
url = me.urlbase + "/patchset" url = me.urlbase + "/patchset"
msg, err := pset.Marshal() msg, err := pset.Marshal()
@ -28,7 +27,6 @@ func sendPatches(pset *forgepb.Patchset) error {
} }
test := strings.TrimSpace(string(body)) test := strings.TrimSpace(string(body))
// log.Info("virtigo returned body:", test)
for _, line := range strings.Split(test, "\n") { for _, line := range strings.Split(test, "\n") {
log.Info("got back:", line) log.Info("got back:", line)
} }
@ -121,28 +119,19 @@ func getPatch(pbfile string) (*forgepb.Patchset, error) {
return pset, nil return pset, nil
} }
/*
func sendDevelDiff(name string) error { func sendDevelDiff(name string) error {
pset, err := me.forge.MakeDevelPatchSet() pset, err := me.forge.MakeDevelPatchSet(name)
if err != nil { if err != nil {
return err return err
} }
pset.Name = name
if os.Getenv("GIT_AUTHOR_NAME") == "" {
return fmt.Errorf("GIT_AUTHOR_NAME not set")
} else {
pset.GitAuthorName = os.Getenv("GIT_AUTHOR_NAME")
}
if os.Getenv("GIT_AUTHOR_EMAIL") == "" {
return fmt.Errorf("GIT_AUTHOR_EMAIL not set")
} else {
pset.GitAuthorEmail = os.Getenv("GIT_AUTHOR_EMAIL")
}
if err := sendPatches(pset); err != nil { if err := sendPatches(pset); err != nil {
return err return err
} }
return nil return nil
} }
*/
func sendMasterDiff() { func sendMasterDiff() {
pset, err := me.forge.MakeMasterPatchSet() pset, err := me.forge.MakeMasterPatchSet()

View File

@ -1,61 +0,0 @@
package main
import (
"sync"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
"go.wit.com/gui"
)
// Shout out to "Go Generics 101" by Tapir Liu. Buy this book!
type Lockable[T any] struct {
mu sync.Mutex
data T
}
func (l *Lockable[T]) Do(f func(*T)) {
}
func (l *Lockable[T]) Hide() {
log.Info("testing:", l)
}
type applyWindow struct {
win *gadgets.BasicWindow
box *gui.Node
// the top box of the repolist window
topbox *gui.Node
}
type C3 = interface {
Show()
Hide()
Hidden() bool
Enable()
Disable()
~*gadgets.BasicWindow | ~*gui.Node
}
func (r applyWindow) Hidden() bool {
return r.win.Hidden()
}
func (r applyWindow) Show() {
r.win.Show()
}
func (r applyWindow) Hide() {
r.win.Hide()
}
func (r applyWindow) Disable() {
r.box.Disable()
}
func (r applyWindow) Enable() {
r.box.Enable()
}

View File

@ -6,6 +6,7 @@ import (
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log"
) )
type patchSummary struct { type patchSummary struct {
@ -74,8 +75,14 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary {
s.submitB.Disable() s.submitB.Disable()
} }
} }
s.submitB = s.grid.NewButton("Create", func() { s.submitB = s.grid.NewButton("Submit", func() {
doSubmit(s.reason.String()) pset, err := me.forge.SubmitDevelPatchSet(s.reason.String())
if err != nil {
log.Info(err)
return
}
line := "somedate some reason Author: me" + pset.GitAuthorEmail
me.patchWin.addPatchset(line)
}) })
/* /*