more work on patches

This commit is contained in:
Jeff Carr 2025-09-04 18:32:01 -05:00
parent 19ce7eef56
commit 78e883a106
8 changed files with 67 additions and 29 deletions

View File

@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
# make andlabs # try the andlabs gui plugin (uses GTK) # make andlabs # try the andlabs gui plugin (uses GTK)
default: verbose install default: verbose install
forge patch list forge patch
vet: vet:
@GO111MODULE=off go vet @GO111MODULE=off go vet

View File

@ -66,7 +66,8 @@ type PatchCmd struct {
List *EmptyCmd `arg:"subcommand:list" help:"your downloaded patchsets"` List *EmptyCmd `arg:"subcommand:list" help:"your downloaded patchsets"`
Get *EmptyCmd `arg:"subcommand:get" help:"get the new patchsets"` Get *EmptyCmd `arg:"subcommand:get" help:"get the new patchsets"`
Show *EmptyCmd `arg:"subcommand:show" help:"your pending commits to your code"` Show *EmptyCmd `arg:"subcommand:show" help:"your pending commits to your code"`
Submit *SubmitCmd `arg:"subcommand:submit" help:"submit your commits"` Submit *SubmitCmd `arg:"subcommand:submit" help:"submit your commits"`
Repos *SubmitCmd `arg:"subcommand:repos" help:"show repos with patches"`
} }
type SubmitCmd struct { type SubmitCmd struct {

View File

@ -46,7 +46,7 @@ func (args) doBashAuto() {
case "pull": case "pull":
fmt.Println("dirty clean list patches --force") fmt.Println("dirty clean list patches --force")
case "patch": case "patch":
fmt.Println("check get list submit show") fmt.Println("check get list repos submit show")
case "user": case "user":
fmt.Println("--force") fmt.Println("--force")
case "devel": case "devel":

View File

@ -14,6 +14,7 @@ import (
"go.wit.com/lib/fhelp" "go.wit.com/lib/fhelp"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/shell" "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
) )
@ -168,28 +169,32 @@ func drawWindow(win *gadgets.GenericWindow) {
patchesWin.Toggle() patchesWin.Toggle()
return return
} }
// me.forge.GetPatches() // load the current patches protobuf file
// loadUpstreamPatchsets() if err := me.forge.LoadPatchsets(); err != nil {
/* log.Info("patches failed to open", err)
if me.psets == nil { if err := me.forge.SavePatchsets(); err != nil {
log.Info("failed to download current patchsets") log.Warn("savePatchsets() failed", err)
return
} }
notdone := new(forgepb.Patches) }
// patchesWin = makePatchesWin(me.forge.Patchsets)
notdone := new(forgepb.Patches)
all := me.psets.All() if me.forge.Patchsets == nil {
for all.Scan() { log.Info("patchsets == nil")
pset := all.Next() return
AddNotDonePatches(notdone, pset, false) }
} all := me.forge.Patchsets.All()
for all.Scan() {
pset := all.Next()
AddAllPatches(notdone, pset, false)
// AddNotDonePatches(notdone, pset, false)
}
for patch := range notdone.IterAll() { for patch := range notdone.IterAll() {
comment := cleanSubject(patch.Comment) comment := cleanSubject(patch.Comment)
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment) log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
} }
// savePatchsets() patchesWin = makePatchesWin(notdone)
patchesWin = makePatchesWin(notdone)
*/
}) })
var pubWin *gadgets.GenericWindow var pubWin *gadgets.GenericWindow

View File

@ -13,7 +13,7 @@ import (
) )
func doNormal() bool { func doNormal() bool {
me.forge.CheckDirty() me.forge.CheckDirtyQuiet()
var count int var count int
stats := me.forge.RillRepos(checkNormalRepoState) stats := me.forge.RillRepos(checkNormalRepoState)

View File

@ -56,18 +56,27 @@ func doPatch() error {
return nil return nil
} }
if argv.Patch.Repos != nil {
dumpDirtyRepos()
}
// if nothing, show patches & dirty repos
me.forge.Patchsets.PrintTable()
dumpDirtyRepos()
return nil
}
func dumpDirtyRepos() {
// always run dirty first // always run dirty first
me.forge.CheckDirty() me.forge.CheckDirtyQuiet()
// if no option is given to patch, list out the // if no option is given to patch, list out the
// repos that have patches ready in them // repos that have patches ready in them
found := findReposWithPatches() found := findReposWithPatches()
if found.Len() == 0 { if found.Len() == 0 {
log.Info("you currently have no patches in your user branches") log.Info("you currently have no repos with patches")
return nil
} }
me.forge.PrintHumanTable(found) me.forge.PrintHumanTable(found)
return nil
} }
// returns bad if patches can not be applied // returns bad if patches can not be applied

View File

@ -178,7 +178,6 @@ func setNewCommitHash(p *forgepb.Patchset) bool {
return done return done
} }
/*
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) { func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
for patch := range pset.Patches.IterAll() { for patch := range pset.Patches.IterAll() {
comment := cleanSubject(patch.Comment) comment := cleanSubject(patch.Comment)
@ -222,4 +221,18 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bo
notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
} }
} }
*/
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
for patch := range pset.Patches.IterAll() {
comment := cleanSubject(patch.Comment)
if found := notdone.FindByCommitHash(patch.CommitHash); found != nil {
log.Info("duplicate commit hash", patch.Namespace, "patch:", patch.NewHash, "commithash:", patch.CommitHash, comment)
continue
}
newhash, _ := findCommitByHash(patch.StartHash, comment)
log.Info("adding patch:", patch.Namespace, patch.CommitHash, comment, newhash)
notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
}
}

View File

@ -158,6 +158,16 @@ func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
dwin.TB.Custom(f) dwin.TB.Custom(f)
} }
// used by the PB table
func funcApplyPatch(p *forgepb.Patch) string {
rn := p.Namespace
if repo := me.forge.FindByGoPath(rn); repo == nil {
// log.Info("Could not figure out repo path", rn)
return ""
}
return "git am"
}
// define what rows to have in the protobuf table // define what rows to have in the protobuf table
func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable { func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
t := pb.NewTable("PatchesPB") t := pb.NewTable("PatchesPB")