slim down this window to keep it functional

This commit is contained in:
Jeff Carr 2025-01-29 11:23:34 -06:00
parent e548b0fb6d
commit 54b50299f3
2 changed files with 49 additions and 82 deletions

View File

@ -114,16 +114,7 @@ func (r *patchesWindow) addPatchset(line string) {
r.setgrid.NewLabel(name) r.setgrid.NewLabel(name)
r.setgrid.NewLabel(subject) r.setgrid.NewLabel(subject)
r.setgrid.NewLabel(author) r.setgrid.NewLabel(author)
/*
r.setgrid.NewButton("Download", func() {
pset, err := savePatch(name)
if err != nil {
log.Info(name, "failed to download", err)
return
}
r.setlist[name] = pset
})
*/
r.setgrid.NewButton("View", func() { r.setgrid.NewButton("View", func() {
// has the window already been created? // has the window already been created?
win := r.setwin[name] win := r.setwin[name]
@ -143,44 +134,5 @@ func (r *patchesWindow) addPatchset(line string) {
r.setwin[name] = makePatchWindow(pset) r.setwin[name] = makePatchWindow(pset)
r.setwin[name].Show() r.setwin[name].Show()
}) })
r.setgrid.NewButton("Dump", func() {
pset := r.setlist[name]
if pset == nil {
log.Info(name, "was nil")
return
}
if !dumpPatchset(pset) {
log.Info("Dump: some patches are bad", name)
return
}
})
r.setgrid.NewButton("Extract", func() {
pset := r.setlist[name]
if pset == nil {
log.Info(name, "was nil")
return
}
if err := savePatchset(pset); err != nil {
log.Info("Save: some patches are bad", name, err)
return
}
})
r.setgrid.NewButton("Apply", func() {
pset := r.setlist[name]
if pset == nil {
log.Info(name, "was nil")
return
}
if _, _, _, err := IsEverythingOnDevel(); err != nil {
log.Info("You can only apply patches to the devel branch")
return
}
if IsAnythingDirty() {
log.Info("You can't apply patches when repos are dirty")
me.forge.PrintHumanTable(me.found)
return
}
applyPatchset(pset)
})
r.setgrid.NextRow() r.setgrid.NextRow()
} }

View File

@ -1,11 +1,11 @@
package main package main
import ( import (
"strings"
"sync" "sync"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui" "go.wit.com/gui"
@ -85,13 +85,13 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
grid.NewLabel(pset.EndBranchHash) grid.NewLabel(pset.EndBranchHash)
grid.NextRow() grid.NextRow()
grid.NewButton("Extract", func() { grid.NewButton("Extract files to disk", func() {
if err := savePatchset(pset); err != nil { if err := savePatchset(pset); err != nil {
log.Info("Save err:", err) log.Info("Save err:", err)
return return
} }
}) })
grid.NewButton("Apply", func() { grid.NewButton("Apply with git am", func() {
if _, _, _, err := IsEverythingOnDevel(); err != nil { if _, _, _, err := IsEverythingOnDevel(); err != nil {
log.Info("You can only apply patches to the devel branch") log.Info("You can only apply patches to the devel branch")
return return
@ -108,39 +108,54 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
g := pw.stack.NewGroup("PatchSet List") g := pw.stack.NewGroup("PatchSet List")
// add the patch grid // make a grid and a header
filegrid := g.NewGrid("", 0, 0) filegrid := g.NewGrid("", 0, 0)
filegrid.NewLabel("repo")
all := pset.Patches.SortByFilename() filegrid.NewLabel("patch name")
for all.Scan() { filegrid.NewLabel("Applied in current branch?")
p := all.Next() filegrid.NewLabel("start hash")
// if IsValidPatch(p) {
filegrid.NewLabel(p.RepoNamespace)
filegrid.NewLabel(p.Comment)
filegrid.NewLabel(p.Filename)
filegrid.NewLabel(p.RepoPath)
filegrid.NewLabel(p.BranchName)
filegrid.NewLabel(p.BranchHash)
filegrid.NewLabel(p.CommitHash)
filegrid.NewLabel(p.StartHash)
filegrid.NextRow() filegrid.NextRow()
}
// add the patches to the grid
pw.addPatchset(filegrid, pset)
return pw return pw
} }
func (r *patchWindow) addPatchset(line string) { func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
parts := strings.Split(line, "Author:") repomap := make(map[*gitpb.Repo][]*forgepb.Patch)
author := parts[1] repohash := make(map[*gitpb.Repo]string)
parts = strings.Fields(parts[0])
name := parts[0] // sort patches by repo namespace
subject := strings.Join(parts[1:], " ") all := pset.Patches.SortByFilename()
r.setgrid.NewLabel(name) for all.Scan() {
r.setgrid.NewLabel(subject) p := all.Next()
r.setgrid.NewLabel(author) s := p.RepoNamespace
r.setgrid.NewButton("Download", func() { repo := me.forge.FindByGoPath(s)
if repo == nil {
log.Info("COULD NOT FIND", s)
continue
}
repomap[repo] = append(repomap[repo], p)
repohash[repo] = p.StartHash
}
// var repo *gitpb.Repo
for repo, patches := range repomap {
log.Info(repo.GetGoPath())
grid.NewLabel(repo.GetGoPath())
for i, p := range patches {
log.Info(i, p.Filename)
grid.NewLabel(p.Comment)
grid.NewLabel("in current branch?")
break
}
hash := repohash[repo]
grid.NewLabel(hash)
grid.NewButton("View", func() {
log.Info("todo: show patches for repo", repo.GetGoPath())
}) })
r.setgrid.NewButton("Apply", func() { grid.NextRow()
}) }
r.setgrid.NextRow()
} }