@@ -39,10 +39,11 @@ def __init__(
3939 self ._metadata = {
4040 "name" : self .name ,
4141 "player_unique_id" : self ._player_unique_id ,
42- "diff" : {0 : "" }, # mapping round -> diff
4342 "created_timestamp" : int (time .time ()),
4443 "config" : self .config ,
4544 "initial_commit_hash" : self ._get_commit_hash (),
45+ "branch_name" : self ._branch_name ,
46+ "round_tags" : {}, # mapping round -> tag
4647 }
4748
4849 if self .push :
@@ -64,17 +65,24 @@ def pre_run_hook(self, *, new_round: int) -> None:
6465 self ._tag_round (0 )
6566 self .game_context .round = new_round
6667
67- def _write_changes_to_file (self , * , round : int , incremental_diff : str , modified_files : dict [ str , str ] ) -> None :
68- """Write incremental changes to a JSON file in players/{name}/changes_r{round}.json"""
68+ def _write_changes_to_file (self , * , round : int ) -> None :
69+ """Write all changes to a JSON file in players/{name}/changes_r{round}.json"""
6970 if round == 0 :
7071 return # No changes for round 0
7172
73+ # Generate all diffs and extract modified files
74+ raw_diff = self ._get_round_diff (round )
75+ filtered_diff = filter_git_diff (raw_diff )
76+ incremental_diff = self ._get_round_diff (round , incremental = True )
77+ modified_files = self ._extract_modified_files_from_diff (filtered_diff )
78+
7279 player_dir = self .game_context .log_local / "players" / self .name
7380 player_dir .mkdir (parents = True , exist_ok = True )
7481
7582 changes_file = player_dir / f"changes_r{ round } .json"
7683 changes_data = {
7784 "round" : round ,
85+ "full_diff" : raw_diff ,
7886 "incremental_diff" : incremental_diff ,
7987 "modified_files" : modified_files ,
8088 "timestamp" : int (time .time ()),
@@ -86,14 +94,9 @@ def _write_changes_to_file(self, *, round: int, incremental_diff: str, modified_
8694 def post_run_hook (self , * , round : int ) -> None :
8795 """Should be called after we called the run method."""
8896 self ._commit ()
89- raw_diff = self ._get_round_diff (round )
90- filtered_diff = filter_git_diff (raw_diff )
91- self ._metadata ["diff" ][round ] = raw_diff
9297
93- # Write incremental changes to separate JSON file
94- incremental_diff = self ._get_round_diff (round , incremental = True )
95- modified_files = self ._extract_modified_files_from_diff (filtered_diff )
96- self ._write_changes_to_file (round = round , incremental_diff = incremental_diff , modified_files = modified_files )
98+ # Write all changes to separate JSON file
99+ self ._write_changes_to_file (round = round )
97100
98101 if self .push :
99102 for cmd in [
@@ -144,10 +147,12 @@ def reset_and_apply_patch(self, patch: str, *, base_commit: str = "", filter_pat
144147
145148 def _tag_round (self , round : int ) -> None :
146149 """Git tag the codebase at the given round."""
150+ tag = self ._get_round_tag_name (round )
147151 assert_zero_exit_code (
148- self .environment .execute (f"git tag -a { self . _get_round_tag_name ( round ) } -m 'Round { round } Update'" ),
152+ self .environment .execute (f"git tag -a { tag } -m 'Round { round } Update'" ),
149153 logger = self .logger ,
150154 )
155+ self ._metadata ["round_tags" ][round ] = tag
151156
152157 @property
153158 def _branch_name (self ) -> str :
0 commit comments