diff options
| author | Jeff Carr <[email protected]> | 2025-10-13 03:43:41 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-13 03:43:41 -0500 |
| commit | 71138fb15b014200cc9c18e9c903700794947678 (patch) | |
| tree | c74d022fb732b182b280976d8c718a0f7fde3d1a | |
| parent | 5ada1a6aa264e8762f595878caf2059ab1d25386 (diff) | |
patch process getting betterv0.25.83
| -rw-r--r-- | doPatch.go | 85 | ||||
| -rw-r--r-- | findByPatchId.go (renamed from doPatch.findByPatchId.go) | 0 |
2 files changed, 51 insertions, 34 deletions
@@ -12,7 +12,6 @@ import ( "path/filepath" "regexp" "strings" - "time" "go.wit.com/lib/fhelp" "go.wit.com/lib/protobuf/forgepb" @@ -98,6 +97,7 @@ func doPatchSubmit() (string, error) { func doPatchProcess() (string, error) { var needfix int + needapply := forgepb.NewPatches() for patch := range me.curpatches.IterAll() { repo := me.forge.Repos.FindByNamespace(patch.Namespace) if repo == nil { @@ -149,41 +149,61 @@ func doPatchProcess() (string, error) { } // log.Info(patch.PatchId, newId, repo.Namespace, "new patch", patch.Comment) patch.State = "new patch" + needapply.Clone(patch) + } + var applycounter int + for patch := range needapply.IterAll() { + repo := me.forge.Repos.FindByNamespace(patch.Namespace) + if repo == nil { + if argv.Verbose { + // dump the whole patch + log.Info("skipping patch for unknown namespace", patch.Namespace) + } + continue + } if !argv.Patch.Apply { + // --apply isn't set. don't go any further needfix += 1 - } else { + continue + } + // show some of the patch details + if argv.Verbose { + // dump the whole patch log.Info(string(patch.Data)) - log.Info(repo.FullPath, "todo: show last commit to repo here") - log.Info(repo.FullPath, patch.Comment) - for _, fname := range patch.Files { - log.Info(repo.FullPath, fname) + } + log.Info(repo.FullPath, "") + log.Info(repo.FullPath, patch.Comment) + for _, fname := range patch.Files { + log.Info(repo.FullPath, fname) + } + for _, line := range strings.Split(string(patch.Data), "\n") { + // log.Info(repo.FullPath, line) + if strings.HasPrefix(line, "From: ") { + log.Info(repo.FullPath, line) + continue } - for _, line := range strings.Split(string(patch.Data), "\n") { - // log.Info(repo.FullPath, line) - if strings.HasPrefix(line, "From: ") { - log.Info(repo.FullPath, line) - continue - } - if strings.HasPrefix(line, "Date: ") { - log.Info(repo.FullPath, line) - continue - } - if strings.HasPrefix(line, "---") { - break - } - if line == "-- " { - break - } + if strings.HasPrefix(line, "Date: ") { + log.Info(repo.FullPath, line) + continue } - log.Info(repo.FullPath, patch.Gan, patch.Gae, patch.GaI) - if fhelp.QuestionUser("apply this patch? (--force to autoapply)") { - newhash, err := applyPatch(repo, patch) - if err != nil { - log.Info("apply results:", newhash, err) - } - if err != nil { - return "git am problem. manually investigate or purge everything and start over", err - } + if strings.HasPrefix(line, "---") { + break + } + if line == "-- " { + break + } + } + log.Info(repo.FullPath, patch.Gan, patch.Gae, patch.GaI) + // prompt user to apply patch + applycounter += 1 + s := log.Sprintf("apply this patch (%d/%d)? (--force to autoapply)", applycounter, needapply.Len()) + if fhelp.QuestionUser(s) { + newhash, err := applyPatch(repo, patch) + if err != nil { + log.Info("apply results:", newhash, err) + } + if err != nil { + return "git am problem. manually investigate or purge everything and start over", err } } } @@ -289,9 +309,6 @@ func applyPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) { } log.Info(cmd) log.Info("everything worked ok") - log.Info("sleep 5") - time.Sleep(5 * time.Second) - return "patch applied with git am", nil } diff --git a/doPatch.findByPatchId.go b/findByPatchId.go index 6882055..6882055 100644 --- a/doPatch.findByPatchId.go +++ b/findByPatchId.go |
