diff options
Diffstat (limited to 'doPatch.go')
| -rw-r--r-- | doPatch.go | 95 |
1 files changed, 45 insertions, 50 deletions
@@ -14,22 +14,6 @@ import ( "go.wit.com/log" ) -func doPatchInit() { - if me.forge.Patchsets != nil { - if me.forge.Patchsets.Len() == 0 { - // log.Info("IGNORE: patches are empty") - } else { - log.Info("IGNORE: patches already initalized len =", me.forge.Patchsets.Len()) - } - } - if err := me.forge.LoadPatchsets(); err != nil { - log.Info("patches failed to open", err) - if err := me.forge.SavePatchsets(); err != nil { - log.Warn("savePatchsets() failed", err) - } - } -} - func isPatchingSafe() bool { if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL { return true @@ -84,47 +68,58 @@ func doPatch() error { } if argv.Patch.List != nil { - log.Info("todo: fix this") - curpatches := forgepb.NewPatches() - curpatches.Filename = "/tmp/curpatches.pb" - if err := curpatches.Load(); err != nil { - return err + err := doPatchList() + return err + } + + err := doPatchList() + return err +} + +func doPatchList() error { + curpatches := forgepb.NewPatches() + curpatches.Filename = "/tmp/curpatches.pb" + if err := curpatches.Load(); err != nil { + return err + } + curpatches.PrintTable() + 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) + continue } - curpatches.PrintTable() - 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) - continue - } - newId, newHash, err := isPatchIdApplied(repo, patch) - if errors.Is(err, ErrorGitPullOnDirty) { - log.Info("a patch with that comment couldn't be found in the repo") - } else if err != nil { - log.Info("err", patch.PatchId, patch.Namespace, patch.Comment, err) - return patch.Error(err) - } - if (newId == patch.PatchId) && (newHash == patch.CommitHash) { - log.Info(patch.PatchId, "patch made here", patch.Comment) - continue - } - if newId == patch.PatchId { - log.Info(patch.PatchId, "patch already applied", patch.Comment) - continue - } - if newId != patch.PatchId { - log.Info(patch.PatchId, "probably duplicate subject", patch.Comment) - } - log.Info("new patch", patch.PatchId, patch.Comment) + newId, newHash, err := isPatchIdApplied(repo, patch) + if errors.Is(err, ErrorGitPullOnDirty) { + log.Info("a patch with that comment couldn't be found in the repo") + } else if err != nil { + log.Info("err", patch.PatchId, patch.Namespace, patch.Comment, err) + return patch.Error(err) + } + if (newId == patch.PatchId) && (newHash == patch.CommitHash) { + log.Info(patch.PatchId, "patch made here", patch.Comment) + continue + } + if newId == patch.PatchId { + log.Info(patch.PatchId, "patch already applied", patch.Comment) + continue + } + if newId != patch.PatchId { + log.Info(patch.PatchId, "probably duplicate subject", patch.Comment) + } + log.Info("new patch", patch.PatchId, patch.Comment) + if !argv.Fix { + log.Info("use --fix to attempt to apply new patches") + } else { if fhelp.QuestionUser("apply this patch?") { newhash, err := applyPatch(repo, patch) log.Info("apply results:", newhash, err) + if err != nil { + return err + } } } - return nil } - - log.Info("todo: fix this") return nil } |
