summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-12 09:37:19 -0500
committerJeff Carr <[email protected]>2025-03-12 09:37:19 -0500
commit6012733385617289b3ac82b9a5608a15a34092bf (patch)
tree26aa9452d218bc09d2903c4c771011a8321f18fd
parent695da486d28ebbb61fa556ba21470a526c2cb2c8 (diff)
individual 'git am' buttonsv0.22.107
-rw-r--r--windowNewPatchsets.go9
-rw-r--r--windowPatches.go30
2 files changed, 30 insertions, 9 deletions
diff --git a/windowNewPatchsets.go b/windowNewPatchsets.go
index a32fd4e..f5a786f 100644
--- a/windowNewPatchsets.go
+++ b/windowNewPatchsets.go
@@ -149,15 +149,6 @@ func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTab
return fmt.Sprintf("%d", p.Patches.Len())
})
- testf := func(p *forgepb.Patchset) string {
- return "validate"
- }
- tp := t.AddButtonFunc("Analyze", testf)
- tp.Custom = func(p *forgepb.Patchset) {
- setPatchsetState(p)
- log.Info("patchset state", p.Name, "is", p.State)
- }
-
vp := t.AddButtonFunc("View Patchset", func(p *forgepb.Patchset) string {
return p.Name
})
diff --git a/windowPatches.go b/windowPatches.go
index b23735b..b12a061 100644
--- a/windowPatches.go
+++ b/windowPatches.go
@@ -94,6 +94,24 @@ func makePatchesWin(patches *forgepb.Patches) *stdPatchTableWin {
return dwin
}
+func applyPatchNew(p *forgepb.Patch) error {
+ rn := p.RepoNamespace
+ repo := me.forge.FindByGoPath(rn)
+ if repo == nil {
+ return fmt.Errorf("Could not figure out repo path %s", rn)
+ }
+ filename, err := savePatch(p)
+ if err != nil {
+ log.Info("savePatch() failed", err)
+ return err
+ }
+ if err := applyPatch(repo, filename); err != nil {
+ log.Info("warn user of git am error", err)
+ return err
+ }
+ return nil
+}
+
func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
dwin.Lock()
defer dwin.Unlock()
@@ -116,6 +134,18 @@ func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
t.NewUuid()
t.SetParent(tbox)
+ gitam := t.AddButtonFunc("apply", func(p *forgepb.Patch) string {
+ return "git am"
+ })
+ gitam.Custom = func(p *forgepb.Patch) {
+ if err := applyPatchNew(p); err != nil {
+ log.Info("git am failed on file", p.Filename, "with error", err)
+ return
+ }
+ log.Info("ran: git am", p.Filename, "ok")
+ }
+
+ t.AddCommitHash()
t.AddRepoNamespace()
// t.AddFilename()
t.AddStringFunc("file", func(p *forgepb.Patch) string {