summaryrefslogtreecommitdiff
path: root/doPatch.go
diff options
context:
space:
mode:
Diffstat (limited to 'doPatch.go')
-rw-r--r--doPatch.go57
1 files changed, 32 insertions, 25 deletions
diff --git a/doPatch.go b/doPatch.go
index c7dee62..111cf8c 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -50,11 +50,11 @@ func doPatch() (string, error) {
return "all current patches: " + footer, nil
}
- if argv.Patch.Get {
- psets := forgepb.NewSets()
- newpb, _, _ := psets.HttpPostVerbose(myServer(), "get")
- footer, err := doPatchGet(newpb)
- return footer, err
+ psets := forgepb.NewSets()
+ newpb, _, _ := psets.HttpPostVerbose(myServer(), "get")
+ footer, err := doPatchGet(newpb)
+ if footer == "" {
+ log.Info(footer)
}
// forces patching to be done in 'NORMAL' mode
@@ -246,31 +246,31 @@ func applyPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) {
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
+ // 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
+ // git apply --reject /tmp/0001-renamed-file-and-added-stuff.patch
- Step 4: Fix the Conflict
+ 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.
+ 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
+ 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.
+ 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
+ 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.
+ git reset --hard HEAD
+ git clean -fd # The -f flag forces the removal, and -d removes untracked directories.
*/
cmd = []string{"git", "am", tmpname}
@@ -305,6 +305,8 @@ func doPatchGet(newpb *forgepb.Sets) (string, error) {
curpatches.Filename = "/tmp/curpatches.pb"
curpatches.Save()
}
+
+ newpatches := forgepb.NewPatches()
for pset := range newpb.IterAll() {
if pset.Patches.Len() == 0 {
log.Info("pset is empty", pset.Name)
@@ -335,11 +337,16 @@ func doPatchGet(newpb *forgepb.Sets) (string, error) {
// gitpb.FindPatchIdFromGitAmBroken(patch.Data) // doesn't os.Exec()
log.Info("adding new patch", patch.CommitHash, patch.PatchId, patch.Filename)
curpatches.AppendByPatchId(patch)
+ newpatches.AppendByPatchId(patch)
}
}
curpatches.Save()
- footer := curpatches.PrintTable()
- return footer, nil
+ if newpatches.Len() == 0 {
+ return "", nil
+ }
+ footer := newpatches.PrintTable()
+ s := log.Sprintf("got %d new patches. %s", newpatches.Len(), footer)
+ return s, nil
}
var ErrorGitPullOnDirty error = errors.New("git comment is not there")