summaryrefslogtreecommitdiff
path: root/makima/src
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-17 19:40:53 +0000
committerGitHub <noreply@github.com>2026-02-17 19:40:53 +0000
commit720ebdac2f64ce18e1de68d070cd3fe46f44547c (patch)
tree58b0be6c0c137e23730dde5434469ef33a2a0525 /makima/src
parent482bed06b470a12347461ee2254ea1ad41f36aaf (diff)
downloadsoryu-720ebdac2f64ce18e1de68d070cd3fe46f44547c.tar.gz
soryu-720ebdac2f64ce18e1de68d070cd3fe46f44547c.zip
feat: soryu-co/soryu - makima: Fix PR creation to update base branch and prevent merge conflicts (#71)
Diffstat (limited to 'makima/src')
-rw-r--r--makima/src/daemon/worktree/manager.rs26
-rw-r--r--makima/src/orchestration/directive.rs1
2 files changed, 25 insertions, 2 deletions
diff --git a/makima/src/daemon/worktree/manager.rs b/makima/src/daemon/worktree/manager.rs
index 5df9a73..c27bcf6 100644
--- a/makima/src/daemon/worktree/manager.rs
+++ b/makima/src/daemon/worktree/manager.rs
@@ -484,7 +484,29 @@ impl WorktreeManager {
"Creating worktree with new branch"
);
- // Create the worktree with a new branch based on the local base_branch
+ // Prefer origin/{base_branch} to get latest remote state
+ let origin_ref = format!("origin/{}", base_branch);
+ let has_origin_ref = Command::new("git")
+ .args(["rev-parse", "--verify", &format!("refs/remotes/{}", origin_ref)])
+ .current_dir(source_repo)
+ .output()
+ .await
+ .map(|o| o.status.success())
+ .unwrap_or(false);
+
+ let start_point = if has_origin_ref {
+ origin_ref.as_str()
+ } else {
+ base_branch
+ };
+
+ tracing::info!(
+ task_id = %task_id,
+ start_point = %start_point,
+ "Using start point for new worktree branch"
+ );
+
+ // Create the worktree with a new branch based on the start point
let output = Command::new("git")
.args([
"worktree",
@@ -493,7 +515,7 @@ impl WorktreeManager {
&branch_name,
])
.arg(&worktree_path)
- .arg(base_branch)
+ .arg(start_point)
.current_dir(source_repo)
.output()
.await?;
diff --git a/makima/src/orchestration/directive.rs b/makima/src/orchestration/directive.rs
index 21053f3..a6bb85b 100644
--- a/makima/src/orchestration/directive.rs
+++ b/makima/src/orchestration/directive.rs
@@ -1414,6 +1414,7 @@ Run these commands:
git fetch origin
git checkout {directive_branch}
git pull origin {directive_branch}
+git merge origin/{base_branch} --no-edit
{merge_commands}
git push origin {directive_branch}
```