Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

tweaks to apply logic, git stash

Dane Schneider788e7d5f69f9
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.go
index 1ad2adc7..a5ba8767 100644
--- a/app/cli/lib/apply.go
+++ b/app/cli/lib/apply.go
@@ -279,7 +279,7 @@ func ApplyPlanWithOutput(planId, branch string, autoConfirm bool) error {
}
}
- err := GitStashPop(conflictStrategy)
+ err := GitStashPop(true)
if err != nil {
fmt.Printf("failed to pop git stash: %v\n", err)
}
diff --git a/app/cli/lib/git.go b/app/cli/lib/git.go
index 002c86b7..6d2ae9a6 100644
--- a/app/cli/lib/git.go
+++ b/app/cli/lib/git.go
@@ -2,8 +2,8 @@ package lib
import (
"fmt"
+ "log"
"os/exec"
- "plandex/types"
"strings"
"sync"
)
@@ -89,33 +89,42 @@ func GitStashCreate(message string) error {
const PopStashConflictMsg = "overwritten by merge"
const ConflictMsgFilesEnd = "commit your changes"
-func GitStashPop(conflictStrategy string) error {
+func GitStashPop(forceOverwrite bool) error {
gitMutex.Lock()
defer gitMutex.Unlock()
res, err := exec.Command("git", "stash", "pop").CombinedOutput()
if err != nil {
+ log.Println("Error popping git stash:", string(res))
+
if strings.Contains(string(res), PopStashConflictMsg) {
- if conflictStrategy != types.PlanOutdatedStrategyOverwrite {
- return fmt.Errorf("conflict popping git stash with unsupported conflict strategy: %s", conflictStrategy)
+ log.Println("Conflicts detected")
+
+ if !forceOverwrite {
+ return fmt.Errorf("conflict popping git stash: %s", string(res))
}
// Parse the output to find which files have conflicts
conflictFiles := parseConflictFiles(string(res))
+
+ log.Println("Conflicting files:", conflictFiles)
+
for _, file := range conflictFiles {
// Reset each conflicting file individually
- err = exec.Command("git", "checkout", "--ours", file).Run()
+ checkoutRes, err := exec.Command("git", "checkout", "--ours", file).CombinedOutput()
if err != nil {
- return fmt.Errorf("error resetting file %s: %v", file, err)
+ return fmt.Errorf("error resetting file %s: %v", file, string(checkoutRes))
}
}
- err = exec.Command("git", "stash", "drop").Run()
+ dropRes, err := exec.Command("git", "stash", "drop").CombinedOutput()
if err != nil {
- return fmt.Errorf("error dropping git stash: %v", err)
+ return fmt.Errorf("error dropping git stash: %v", string(dropRes))
}
return nil
} else {
+ log.Println("No conflicts detected")
+
return fmt.Errorf("error popping git stash: %v", string(res))
}
}
diff --git a/app/server/db/result_helpers.go b/app/server/db/result_helpers.go
index 2ca7301e..81446b37 100644
--- a/app/server/db/result_helpers.go
+++ b/app/server/db/result_helpers.go
@@ -310,17 +310,6 @@ func ApplyPlan(orgId, planId, branch string) error {
}
}
- planState, err := GetCurrentPlanState(CurrentPlanStateParams{
- OrgId: orgId,
- PlanId: planId,
- PlanFileResults: results,
- PendingBuildDescriptions: pendingBuildDescriptions,
- })
-
- if err != nil {
- return fmt.Errorf("error getting current plan state: %v", err)
- }
-
var pendingDbResults []*PlanFileResult
for _, result := range results {
@@ -378,9 +367,9 @@ func ApplyPlan(orgId, planId, branch string) error {
}
}
- msg := "Marked pending results as applied." + "\n\n" + planState.PendingChangesSummary()
+ msg := "Marked pending results as applied."
- err = GitAddAndCommit(orgId, planId, branch, msg)
+ err := GitAddAndCommit(orgId, planId, branch, msg)
if err != nil {
return fmt.Errorf("error committing plan: %v", err)