(
session_files: set[str],
cwd: str | None = None,
)
| 270 | |
| 271 | |
| 272 | def get_commit_attribution( |
| 273 | session_files: set[str], |
| 274 | cwd: str | None = None, |
| 275 | ) -> list[CommitAttribution]: |
| 276 | status = get_file_status(cwd) |
| 277 | results: list[CommitAttribution] = [] |
| 278 | |
| 279 | for file_status in status: |
| 280 | abs_path = os.path.abspath(os.path.join(cwd or os.getcwd(), file_status.path)) |
| 281 | is_claude = abs_path in session_files |
| 282 | |
| 283 | lines_added = 0 |
| 284 | lines_removed = 0 |
| 285 | diff_output = _run_git_ok(["diff", "--", file_status.path], cwd) |
| 286 | if diff_output: |
| 287 | for line in diff_output.splitlines(): |
| 288 | if line.startswith("+") and not line.startswith("+++"): |
| 289 | lines_added += 1 |
| 290 | elif line.startswith("-") and not line.startswith("---"): |
| 291 | lines_removed += 1 |
| 292 | |
| 293 | results.append(CommitAttribution( |
| 294 | path=file_status.path, |
| 295 | modified_by_claude=is_claude, |
| 296 | modified_by_user=not is_claude, |
| 297 | lines_added=lines_added, |
| 298 | lines_removed=lines_removed, |
| 299 | )) |
| 300 | |
| 301 | return results |
| 302 | |
| 303 | |
| 304 | def list_worktrees(cwd: str | None = None) -> list[Worktree]: |
nothing calls this directly
no test coverage detected