MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / get_commit_attribution

Function get_commit_attribution

src/utils/git.py:272–301  ·  view source on GitHub ↗
(
    session_files: set[str],
    cwd: str | None = None,
)

Source from the content-addressed store, hash-verified

270
271
272def 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
304def list_worktrees(cwd: str | None = None) -> list[Worktree]:

Callers

nothing calls this directly

Calls 5

get_file_statusFunction · 0.85
_run_git_okFunction · 0.85
CommitAttributionClass · 0.85
joinMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected