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

Function get_diff_against_branch

src/utils/git.py:218–248  ·  view source on GitHub ↗
(
    branch: str,
    cwd: str | None = None,
)

Source from the content-addressed store, hash-verified

216
217
218def 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
251def create_branch(

Callers

nothing calls this directly

Calls 3

_run_git_okFunction · 0.85
DiffResultClass · 0.85
searchMethod · 0.80

Tested by

no test coverage detected