summaryrefslogtreecommitdiff
path: root/makima/src/daemon/task/manager.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/daemon/task/manager.rs')
-rw-r--r--makima/src/daemon/task/manager.rs31
1 files changed, 22 insertions, 9 deletions
diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs
index 95554e9..0cba516 100644
--- a/makima/src/daemon/task/manager.rs
+++ b/makima/src/daemon/task/manager.rs
@@ -4277,16 +4277,25 @@ impl TaskManagerInner {
target_repo_path: Option<&str>,
target_branch: Option<&str>,
) -> Result<Option<String>, String> {
+ // For PR action, we can use the worktree's origin directly if target_repo_path is not set
let target_repo = match target_repo_path {
- Some(path) => crate::daemon::worktree::expand_tilde(path),
+ Some(path) => Some(crate::daemon::worktree::expand_tilde(path)),
None => {
- tracing::warn!(task_id = %task_id, "No target_repo_path configured, skipping completion action");
- return Ok(None);
+ if action == "pr" {
+ // For PR action, check if worktree has an origin remote we can use directly
+ None
+ } else {
+ tracing::warn!(task_id = %task_id, "No target_repo_path configured, skipping completion action");
+ return Ok(None);
+ }
}
};
- if !target_repo.exists() {
- return Err(format!("Target repo not found: {} (expanded from {:?})", target_repo.display(), target_repo_path));
+ // Validate target_repo exists if provided
+ if let Some(ref repo) = target_repo {
+ if !repo.exists() {
+ return Err(format!("Target repo not found: {} (expanded from {:?})", repo.display(), target_repo_path));
+ }
}
// Get the branch name: makima/{task-name-with-dashes}-{short-id}
@@ -4296,13 +4305,14 @@ impl TaskManagerInner {
crate::daemon::worktree::short_uuid(task_id)
);
- // Determine target branch - use provided value or detect default branch of target repo
+ // Determine target branch - use provided value or detect default branch
let target_branch = match target_branch {
Some(branch) => branch.to_string(),
None => {
- // Detect default branch (main, master, develop, etc.)
+ // Detect default branch from target_repo if available, otherwise from worktree
+ let detect_path = target_repo.as_ref().map(|p| p.as_path()).unwrap_or(worktree_path);
self.worktree_manager
- .detect_default_branch(&target_repo)
+ .detect_default_branch(detect_path)
.await
.unwrap_or_else(|_| "master".to_string())
}
@@ -4317,6 +4327,7 @@ impl TaskManagerInner {
match action {
"branch" => {
+ let target_repo = target_repo.ok_or_else(|| "No target_repo_path configured for branch action".to_string())?;
// Just push the branch to target repo
self.worktree_manager
.push_to_target_repo(worktree_path, &target_repo, &branch_name, task_name)
@@ -4332,6 +4343,7 @@ impl TaskManagerInner {
Ok(None)
}
"merge" => {
+ let target_repo = target_repo.ok_or_else(|| "No target_repo_path configured for merge action".to_string())?;
// Push and merge into target branch
let commit_sha = self.worktree_manager
.merge_to_target(worktree_path, &target_repo, &branch_name, &target_branch, task_name)
@@ -4348,6 +4360,7 @@ impl TaskManagerInner {
}
"pr" => {
// Push and create PR
+ // For PR, we can use target_repo if provided, or create PR directly from worktree
let title = task_name.to_string();
let body = format!(
"Automated PR from makima task.\n\nTask ID: `{}`",
@@ -4356,7 +4369,7 @@ impl TaskManagerInner {
let pr_url = self.worktree_manager
.create_pull_request(
worktree_path,
- &target_repo,
+ target_repo.as_deref(),
&branch_name,
&target_branch,
&title,