MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / _extract_modified_files_from_diff

Method _extract_modified_files_from_diff

codeclash/agents/player.py:212–236  ·  view source on GitHub ↗

Extract modified file paths from a git diff and get their full content. Returns a dict mapping file path to full file content. Only includes common code file extensions.

(self, diff: str)

Source from the content-addressed store, hash-verified

210 tag = self._get_round_tag_name(round)
211 assert_zero_exit_code(
212 self.environment.execute(f"git tag -a {tag} -m '{self._round_message(round)}'"),
213 logger=self.logger,
214 )
215 self._metadata["round_tags"][round] = tag
216
217 def _get_round_tag_name(self, round: int) -> str:
218 """Get git tag name for the version of the codebase at the given round."""
219 return f"{self._player_unique_id}-round-{round}"
220
221 def _get_commit_hash(self) -> str:
222 """Get the current commit hash."""
223 out = assert_zero_exit_code(
224 self.environment.execute("git rev-parse HEAD"),
225 logger=self.logger,
226 )
227 return out["output"].strip()
228
229 def _isolate_git(self) -> None:
230 """Strip the git remote + all remote-tracking refs and tags so the agent cannot read
231 opponents&#x27; pushed code (origin/human/*, <uuid>-round-N). The local working branch and its
232 history remain, so the agent can still commit; push (post_run_hook) re-adds origin briefly.
233 Best-effort — failures here must not abort a run."""
234 for cmd in [
235 "git remote remove origin",
236 "git for-each-ref --format='%(refname)' refs/remotes refs/tags | xargs -r -n1 git update-ref -d",
237 "git reflog expire --expire=now --all",
238 "git gc --prune=now --quiet",
239 "rm -f .git/FETCH_HEAD .git/ORIG_HEAD",

Callers 1

Calls 4

assert_zero_exit_codeFunction · 0.90
getMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected