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)
| 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) |
no test coverage detected