`git diff -p base head` as text on success, None on error. Distinguishing failure from success-with-empty-diff matters: the push-sweep caller marks the tail reviewed when the diff is empty (nothing to review), but on failure (timeout, non-zero exit, missing git) it must NOT mark the
(repo_root, base, head="HEAD")
| 191 | |
| 192 | |
| 193 | def _git_diff_range(repo_root, base, head="HEAD"): |
| 194 | """`git diff -p base head` as text on success, None on error. |
| 195 | |
| 196 | Distinguishing failure from success-with-empty-diff matters: the push-sweep |
| 197 | caller marks the tail reviewed when the diff is empty (nothing to review), |
| 198 | but on failure (timeout, non-zero exit, missing git) it must NOT mark |
| 199 | them reviewed — otherwise unreviewed commits get permanently silenced. |
| 200 | """ |
| 201 | try: |
| 202 | r = subprocess.run( |
| 203 | [*GIT_CMD, "diff", "-p", "--no-color", "--no-ext-diff", base, head], |
| 204 | cwd=repo_root, capture_output=True, timeout=30, |
| 205 | ) |
| 206 | if r.returncode != 0: |
| 207 | return None |
| 208 | return r.stdout.decode("utf-8", errors="replace") |
| 209 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError): |
| 210 | return None |
| 211 | |
| 212 | |
| 213 | def _detect_main_branch(repo_root): |
no outgoing calls
no test coverage detected