99from codeclash .agents .utils import GameContext
1010from codeclash .constants import GH_ORG
1111from codeclash .tournaments .utils .git_utils import filter_git_diff
12- from codeclash .utils .environment import assert_zero_exit_code , create_file_on_container
12+ from codeclash .utils .environment import assert_zero_exit_code , create_file_in_container
1313from codeclash .utils .log import get_logger
1414
1515load_dotenv ()
@@ -25,7 +25,7 @@ def __init__(
2525 self .config = config
2626 self .name = config ["name" ]
2727 self ._player_unique_id = uuid .uuid4 ()
28- """Unique ID that doesn't clash even accross multiple games. Used for git tags."""
28+ """Unique ID that doesn't clash even across multiple games. Used for git tags."""
2929 self .environment = environment
3030 self .game_context = game_context
3131 self .logger = get_logger (
@@ -54,9 +54,7 @@ def post_run_hook(self, *, round: int) -> None:
5454 """Should be called after we called the run method."""
5555 self ._commit ()
5656 self ._metadata ["diff" ][round ] = self ._get_round_diff (round )
57- self ._metadata ["incremental_diff" ][round ] = self ._get_round_diff (
58- round , incremental = True
59- )
57+ self ._metadata ["incremental_diff" ][round ] = self ._get_round_diff (round , incremental = True )
6058
6159 @abstractmethod
6260 def run (self ) -> None :
@@ -79,23 +77,15 @@ def push(self) -> None:
7977 "git push origin --tags" ,
8078 ]:
8179 assert_zero_exit_code (self .environment .execute (cmd ), logger = self .logger )
82- self .logger .info (
83- f"Pushed { self .name } commit history to remote repository (branch { self ._branch_name } )"
84- )
80+ self .logger .info (f"Pushed { self .name } commit history to remote repository (branch { self ._branch_name } )" )
8581
86- def reset_and_apply_patch (
87- self , patch : str , * , base_commit : str = "" , filter_patch : bool = True
88- ) -> None :
89- """Clean all uncommited changes. If base_commit is provided, reset to that commit.
82+ def reset_and_apply_patch (self , patch : str , * , base_commit : str = "" , filter_patch : bool = True ) -> None :
83+ """Clean all uncommitted changes. If base_commit is provided, reset to that commit.
9084 Then apply the patch to the codebase.
9185 """
9286 # Need to clean before we copy over the patch (else it's gonna be removed by git clean)
9387 self .logger .debug (
94- assert_zero_exit_code (
95- self .environment .execute (
96- f"git reset --hard { base_commit } && git clean -fd"
97- )
98- )
88+ assert_zero_exit_code (self .environment .execute (f"git reset --hard { base_commit } && git clean -fd" ))
9989 )
10090
10191 patch = filter_git_diff (patch ) if filter_patch else patch
@@ -104,7 +94,7 @@ def reset_and_apply_patch(
10494 self .logger .debug ("No patch to apply, skipping" )
10595 return
10696
107- create_file_on_container (
97+ create_file_in_container (
10898 container = self .environment , # type: ignore
10999 content = patch ,
110100 dest_path = "tmp_patch.txt" ,
@@ -115,19 +105,15 @@ def reset_and_apply_patch(
115105 commands = ["git status" , "git apply tmp_patch.txt" , "rm -f tmp_patch.txt" ]
116106 for cmd in commands :
117107 self .logger .debug (f"Executing command: { cmd } " )
118- out = assert_zero_exit_code (
119- self .environment .execute (cmd ), logger = self .logger
120- )
108+ out = assert_zero_exit_code (self .environment .execute (cmd ), logger = self .logger )
121109 self .logger .debug (out )
122110
123111 # --- Helper methods ---
124112
125113 def _tag_round (self , round : int ) -> None :
126114 """Git tag the codebase at the given round."""
127115 assert_zero_exit_code (
128- self .environment .execute (
129- f"git tag -a { self ._get_round_tag_name (round )} -m 'Round { round } Update'"
130- ),
116+ self .environment .execute (f"git tag -a { self ._get_round_tag_name (round )} -m 'Round { round } Update'" ),
131117 logger = self .logger ,
132118 )
133119
@@ -164,9 +150,7 @@ def _get_round_diff(self, round: int, *, incremental: bool = False) -> str:
164150 previous_round_tag = self ._get_round_tag_name (0 )
165151 current_round_tag = self ._get_round_tag_name (round )
166152 out = assert_zero_exit_code (
167- self .environment .execute (
168- f"git diff { previous_round_tag } ..{ current_round_tag } "
169- ),
153+ self .environment .execute (f"git diff { previous_round_tag } ..{ current_round_tag } " ),
170154 logger = self .logger ,
171155 )
172156 return out ["output" ]
0 commit comments