diff options
| author | Jeff Carr <[email protected]> | 2025-10-10 17:42:55 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-10 17:42:55 -0500 |
| commit | 501f27c316e053b004765863b51aada48513ba44 (patch) | |
| tree | 66781e6ce628b79b192dcea54debfef291a5bf10 | |
| parent | 1dc89c5ee56624048f985f9794a63016016afb75 (diff) | |
lots of patch cleanups. tool is early stage functional
| -rw-r--r-- | argv.go | 7 | ||||
| -rw-r--r-- | doPatch.go | 57 |
2 files changed, 45 insertions, 19 deletions
@@ -107,9 +107,10 @@ type CleanDevelCmd struct { } type PatchCmd struct { - Get *EmptyCmd `arg:"subcommand:get" help:"get the new patchsets"` - Fix bool `arg:"--fix" help:"actually apply your patches"` - Submit bool `arg:"--resubmit" help:"resubmit your git commits"` + Get bool `arg:"--get" help:"get the new patchsets"` + Show bool `arg:"--show" help:"show all the current patches"` + Fix bool `arg:"--fix" help:"attempt to apply any new patches"` + Submit bool `arg:"--resubmit" help:"resubmit your git commits"` } type PullCmd struct { @@ -39,18 +39,30 @@ func doPatch() (string, error) { return doPatchSubmit() } - if !isPatchingSafe() { - return "not safe", errors.New("not safe to work on patches") + if argv.Patch.Show { + curpatches := forgepb.NewPatches() + curpatches.Filename = "/tmp/curpatches.pb" + if err := curpatches.Load(); err != nil { + return "fix curpatches.pb", err + } + footer := curpatches.PrintTable() + return "all current patches: " + footer, nil } - if argv.Patch.Get != nil { + if argv.Patch.Get { psets := forgepb.NewSets() newpb, _, _ := psets.HttpPostVerbose(myServer(), "get") footer, err := doPatchGet(newpb) return footer, err } - s, err := doPatchList() + // forces patching to be done in 'NORMAL' mode + // forge is too new to be able to handle anything else + if !isPatchingSafe() { + return "not safe", errors.New("not safe to work on patches") + } + + s, err := doPatchProcess() return s, err } @@ -71,19 +83,19 @@ func doPatchSubmit() (string, error) { return footer, err } -func doPatchList() (string, error) { +func doPatchProcess() (string, error) { curpatches := forgepb.NewPatches() curpatches.Filename = "/tmp/curpatches.pb" if err := curpatches.Load(); err != nil { return "fix curpatches.pb", err } - footer := curpatches.PrintTable() - log.Info("START curpatches:", footer) + // footer := curpatches.PrintTable() + // log.Info("START curpatches:", footer) var needfix int for patch := range curpatches.IterAll() { repo := me.forge.Repos.FindByNamespace(patch.Namespace) if repo == nil { - log.Info("no namespace", patch.PatchId, patch.Namespace, patch.Comment) + // log.Info("no namespace", patch.PatchId, patch.Namespace, patch.Comment) patch.State = "no namespace" continue } @@ -144,15 +156,28 @@ func doPatchList() (string, error) { } } } - footer = curpatches.PrintTable() - log.Info("END curpatches:", footer) - var s string - if needfix == 0 { - s = "no new patches" - } else { - s = log.Sprintf("There are %d new patches. Use --fix to apply them", needfix) - curpatches.Save() + // NOW, FINALLY, AFTER A LOT OF WORK, THE FUN PART + newpatches := forgepb.NewPatches() + for p := range curpatches.IterAll() { + if p.NewHash == "author" { + // this is your patch + continue + } + if (p.NewHash != "") && p.StateChange == "did already" { + // already applied + continue + } + newpatches.Clone(p) + } + if newpatches.Len() == 0 { + s := log.Sprintf("All (%d) current patches are appled. You are completely up to date!", curpatches.Len()) + return s, nil } + footer := newpatches.PrintTable() + log.Info("BRAND NEW PATCHES:", footer) + var s string + s = log.Sprintf("There are %d new patches. Use --fix to apply them", needfix) + curpatches.Save() return s, nil } |
