源码: prompt.rs:245-263
(cwd: Path)
| 195 | |
| 196 | |
| 197 | def _read_git_diff(cwd: Path) -> Optional[str]: |
| 198 | """源码: prompt.rs:245-263""" |
| 199 | sections: list[str] = [] |
| 200 | |
| 201 | staged = _read_git_output(cwd, ["diff", "--cached"]) |
| 202 | if staged and staged.strip(): |
| 203 | sections.append(f"Staged changes:\n{staged.rstrip()}") |
| 204 | |
| 205 | unstaged = _read_git_output(cwd, ["diff"]) |
| 206 | if unstaged and unstaged.strip(): |
| 207 | sections.append(f"Unstaged changes:\n{unstaged.rstrip()}") |
| 208 | |
| 209 | return "\n\n".join(sections) if sections else None |
| 210 | |
| 211 | |
| 212 | def _read_git_output(cwd: Path, args: list[str]) -> Optional[str]: |
no test coverage detected