diff options
Diffstat (limited to 'makima/src/daemon')
| -rw-r--r-- | makima/src/daemon/worktree/manager.rs | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/makima/src/daemon/worktree/manager.rs b/makima/src/daemon/worktree/manager.rs index fa8a9de..166e654 100644 --- a/makima/src/daemon/worktree/manager.rs +++ b/makima/src/daemon/worktree/manager.rs @@ -256,8 +256,37 @@ impl WorktreeManager { ))); } - // Fetch latest changes from remote if configured - tracing::info!("Fetching latest changes for local repo: {}", repo_source); + // Check if 'origin' remote exists + let origin_check = Command::new("git") + .args(["remote", "get-url", "origin"]) + .current_dir(&path) + .output() + .await; + + let has_origin = origin_check + .map(|o| o.status.success()) + .unwrap_or(false); + + if has_origin { + // Fetch from origin specifically to get the latest changes + tracing::info!("Fetching latest from origin for local repo: {}", repo_source); + let fetch_output = Command::new("git") + .args(["fetch", "origin"]) + .current_dir(&path) + .output() + .await?; + + if !fetch_output.status.success() { + let stderr = String::from_utf8_lossy(&fetch_output.stderr); + tracing::warn!("Git fetch from origin failed (continuing anyway): {}", stderr); + } else { + tracing::info!("Successfully fetched latest changes from origin for {}", repo_source); + } + } else { + tracing::debug!("Local repo has no origin remote: {}", repo_source); + } + + // Fetch from all remotes (includes any other remotes besides origin) let output = Command::new("git") .args(["fetch", "--all", "--prune"]) .current_dir(&path) @@ -267,9 +296,7 @@ impl WorktreeManager { if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); // Don't fail - repo might not have a remote configured - tracing::debug!("Git fetch for local repo (may not have remote): {}", stderr); - } else { - tracing::info!("Fetched latest changes for {}", repo_source); + tracing::debug!("Git fetch --all for local repo (may not have remote): {}", stderr); } Ok(path) |
