(
branch: str,
cwd: str | None = None,
)
| 216 | |
| 217 | |
| 218 | def get_diff_against_branch( |
| 219 | branch: str, |
| 220 | cwd: str | None = None, |
| 221 | ) -> DiffResult: |
| 222 | diff_output = _run_git_ok(["diff", f"{branch}...HEAD"], cwd) |
| 223 | stat_output = _run_git_ok(["diff", "--stat", f"{branch}...HEAD"], cwd) |
| 224 | |
| 225 | files_changed = 0 |
| 226 | insertions = 0 |
| 227 | deletions = 0 |
| 228 | if stat_output: |
| 229 | lines = stat_output.strip().splitlines() |
| 230 | if lines: |
| 231 | import re |
| 232 | summary = lines[-1] |
| 233 | files_match = re.search(r"(\d+)\s+file", summary) |
| 234 | ins_match = re.search(r"(\d+)\s+insertion", summary) |
| 235 | del_match = re.search(r"(\d+)\s+deletion", summary) |
| 236 | if files_match: |
| 237 | files_changed = int(files_match.group(1)) |
| 238 | if ins_match: |
| 239 | insertions = int(ins_match.group(1)) |
| 240 | if del_match: |
| 241 | deletions = int(del_match.group(1)) |
| 242 | |
| 243 | return DiffResult( |
| 244 | diff_text=diff_output, |
| 245 | files_changed=files_changed, |
| 246 | insertions=insertions, |
| 247 | deletions=deletions, |
| 248 | ) |
| 249 | |
| 250 | |
| 251 | def create_branch( |
nothing calls this directly
no test coverage detected