(cwd: &Path)
| 243 | } |
| 244 | |
| 245 | fn read_git_diff(cwd: &Path) -> Option<String> { |
| 246 | let mut sections = Vec::new(); |
| 247 | |
| 248 | let staged = read_git_output(cwd, &["diff", "--cached"])?; |
| 249 | if !staged.trim().is_empty() { |
| 250 | sections.push(format!("Staged changes:\n{}", staged.trim_end())); |
| 251 | } |
| 252 | |
| 253 | let unstaged = read_git_output(cwd, &["diff"])?; |
| 254 | if !unstaged.trim().is_empty() { |
| 255 | sections.push(format!("Unstaged changes:\n{}", unstaged.trim_end())); |
| 256 | } |
| 257 | |
| 258 | if sections.is_empty() { |
| 259 | None |
| 260 | } else { |
| 261 | Some(sections.join("\n\n")) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | fn read_git_output(cwd: &Path, args: &[&str]) -> Option<String> { |
| 266 | let output = Command::new("git") |
no test coverage detected