summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-11 04:35:45 -0500
committerJeff Carr <[email protected]>2025-10-11 04:35:45 -0500
commitc338f609abc8859a62fce817ae171e038fdd23f0 (patch)
tree8f8ec6bc44100913f4f8fa7f2bc33831aecaf9ae
parenta2331b90f7d0b11e8ca849ad50e0a4a6d590c109 (diff)
improved flowv0.25.78v0.25.77
-rw-r--r--doPatch.go78
1 files changed, 76 insertions, 2 deletions
diff --git a/doPatch.go b/doPatch.go
index 6eb58b6..c7dee62 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"strings"
+ "time"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/protobuf/forgepb"
@@ -147,7 +148,29 @@ func doPatchProcess() (string, error) {
needfix += 1
} else {
log.Info(string(patch.Data))
- log.Info("repo:", repo.FullPath, "patch header:", patch.Comment, patch.CommitHash)
+ 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)
+ }
+ 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
+ }
+ }
+ 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 {
@@ -199,9 +222,56 @@ func applyPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) {
raw.Write(p.Data)
raw.Close()
+ log.Info("")
// always run abort first
cmd := []string{"git", "am", "--abort"}
- err = repo.RunVerbose(cmd)
+ stats := repo.Run(cmd)
+ if stats.Error != nil {
+ panic("git am --abort failed")
+ }
+ log.Info("Ran 'git am --abort' for safety and everything seems ok")
+ // if stats.Outp == nil {
+ // log.Info("todo: move this to linux/ and do things correctly")
+ // }
+
+ // git apply --check /tmp/0001-renamed-file-and-added-stuff.patch
+ cmd = []string{"git", "apply", "--check", tmpname}
+ stats = repo.Run(cmd)
+ if stats.Error != nil {
+ panic("git apply --check failed")
+ }
+ if stats.Exit != 0 {
+ panic("git apply --check failed")
+ }
+ log.Info("Ran 'git apply --check' and everything seems ok")
+
+ /*
+ // The current 'best practice' thanks to Gemini. the current LLM's are useful for this sorta thing
+
+ // git apply --reject /tmp/0001-renamed-file-and-added-stuff.patch
+
+ Step 4: Fix the Conflict
+
+ 1. List the reject files: ls *.rej.
+ 2. Open the .rej file and the corresponding source file (e.g., some/file.go.rej and some/file.go).
+ 3. The .rej file shows you the lines that couldn't be applied. Manually edit your source file to incorporate the changes
+ from the patch correctly.
+ 4. Once you've fixed the file, delete the .rej file.
+
+ Step 5: Commit the Result
+
+ Once all .rej files are gone and your code is in the state you want, you need to finalize the operation. Since you
+ applied the changes manually, you now need to commit them.
+
+ 1 # Add all the files you manually fixed
+ 2 git add .
+ 3
+ 4 # Now, commit the changes. You can get the commit message from the patch file.
+ 5 git commit -F /tmp/0001-renamed-file-and-added-stuff.patch
+
+ git reset --hard HEAD
+ git clean -fd # The -f flag forces the removal, and -d removes untracked directories.
+ */
cmd = []string{"git", "am", tmpname}
err = repo.RunVerbose(cmd)
@@ -212,6 +282,10 @@ func applyPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) {
log.Info("git am failed. run 'git am --abort' here")
return "", log.Errorf("git am failed")
}
+ log.Info(cmd)
+ log.Info("everything worked ok")
+ log.Info("sleep 5")
+ time.Sleep(5 * time.Second)
return "patch applied with git am", nil
}