fix(tui/branch): treat 'nothing to commit/working tree clean' on finalize as success, avoid empty error; continue merge/cleanup flow

This commit is contained in:
James Peter
2025-09-08 11:38:57 +10:00
parent 0cbeb651fc
commit e9d2a2462b
+13 -7
View File
@@ -6242,15 +6242,21 @@ impl ChatWidget<'_> {
.output() .output()
.await; .await;
if let Ok(o) = &commit_out { if let Ok(o) = &commit_out {
if !o.status.success() { if !o.status.success() {
// Ignore "nothing to commit" (exit 1); surface others // Git prints "nothing to commit, working tree clean" on stdout and exits 1.
let msg = String::from_utf8_lossy(&o.stderr); let stderr_s = String::from_utf8_lossy(&o.stderr);
if !msg.contains("nothing to commit") { let stdout_s = String::from_utf8_lossy(&o.stdout);
use codex_core::protocol::{BackgroundEventEvent, Event, EventMsg}; let benign = stdout_s.contains("nothing to commit")
let _ = tx.send(AppEvent::CodexEvent(Event { id: uuid::Uuid::new_v4().to_string(), event_seq: 0, msg: EventMsg::BackgroundEvent(BackgroundEventEvent { message: format!("`/branch finalize` — commit failed: {}", msg.trim()) }), order: None })); || stdout_s.contains("working tree clean")
} || stderr_s.contains("nothing to commit")
|| stderr_s.contains("working tree clean");
if !benign {
use codex_core::protocol::{BackgroundEventEvent, Event, EventMsg};
let detail = if !stderr_s.trim().is_empty() { stderr_s.trim().to_string() } else { stdout_s.trim().to_string() };
let _ = tx.send(AppEvent::CodexEvent(Event { id: uuid::Uuid::new_v4().to_string(), event_seq: 0, msg: EventMsg::BackgroundEvent(BackgroundEventEvent { message: format!("`/branch finalize` — commit failed: {}", detail) }), order: None }));
} }
} }
}
// Determine default branch in main repo // Determine default branch in main repo
let default_branch = match codex_core::git_worktree::detect_default_branch(&git_root).await { let default_branch = match codex_core::git_worktree::detect_default_branch(&git_root).await {