codetether_agent/tui/git_diff.rs
1//! Capture `git diff --stat` for the TUI git view.
2
3use std::path::Path;
4
5/// Staged + unstaged diff stat summary.
6pub fn capture_diff_stat(root: &Path) -> String {
7 let Ok(output) = std::process::Command::new("git")
8 .args(["-C", root.to_string_lossy().as_ref()])
9 .args(["diff", "--stat"])
10 .output()
11 else {
12 return "(unavailable)".into();
13 };
14 let stdout = String::from_utf8_lossy(&output.stdout);
15 if stdout.trim().is_empty() {
16 "Working tree clean.".into()
17 } else {
18 stdout.trim().to_string()
19 }
20}