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

Method _get_round_diff

codeclash/agents/player.py:238–254  ·  view source on GitHub ↗

Get the diff between the round and initial version (round 0). If incremental is True, get the diff between the round and the previous round. Returns empty string if round is 0.

(self, round: int, *, incremental: bool = False)

Source from the content-addressed store, hash-verified

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",
240 ]:
241 self.environment.execute(cmd)
242 self.logger.info("Isolated git: removed origin + opponent branches/tags + FETCH_HEAD (anti-cheat)")
243
244 def _commit(self) -> None:
245 """Commit changes to the agent's codebase."""
246 r = self.game_context.round
247 unstage_binaries = (
248 "git diff --cached --numstat | awk -F'\\t' '$1==\"-\" && $2==\"-\" {print $3}' "
249 "| xargs -r -d '\\n' git reset -q HEAD --"
250 )
251 for cmd in [
252 "git add -A",
253 unstage_binaries,
254 f"git commit --allow-empty -m '{self._round_message(r)}'",
255 ]:
256 assert_zero_exit_code(self.environment.execute(cmd), logger=self.logger)
257 self._tag_round(r)

Callers 1

Calls 3

_get_round_tag_nameMethod · 0.95
assert_zero_exit_codeFunction · 0.90
executeMethod · 0.45

Tested by

no test coverage detected