Skip to content

Commit 2ca92c2

Browse files
author
yolo h8cker 93
committed
Revert "Speedup reset_and_apply_patch"
This reverts commit 3b88363.
1 parent 99c6d8b commit 2ca92c2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

codeclash/agents/player.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ def reset_and_apply_patch(self, patch: str, *, base_commit: str = "", filter_pat
118118
"""Clean all uncommitted changes. If base_commit is provided, reset to that commit.
119119
Then apply the patch to the codebase.
120120
"""
121+
# Need to clean before we copy over the patch (else it's gonna be removed by git clean)
122+
self.logger.debug(
123+
assert_zero_exit_code(self.environment.execute(f"git reset --hard {base_commit} && git clean -fd"))
124+
)
125+
121126
patch = filter_git_diff(patch) if filter_patch else patch
122127

123128
if not patch.strip():
@@ -130,18 +135,13 @@ def reset_and_apply_patch(self, patch: str, *, base_commit: str = "", filter_pat
130135
dest_path="tmp_patch.txt",
131136
)
132137

133-
# Need to clean before we copy over the patch (else it's gonna be removed by git clean)
134-
commands = [
135-
"git reset --hard {base_commit}",
136-
"git clean -fd",
137-
"git status",
138-
"git apply tmp_patch.txt",
139-
"rm -f tmp_patch.txt",
140-
]
141-
cmd = " && ".join(commands)
142-
self.logger.debug(f"Executing command: {cmd}")
143-
out = assert_zero_exit_code(self.environment.execute(cmd), logger=self.logger)
144-
self.logger.debug(out)
138+
self.logger.debug(f"Applying patch to agent's codebase: {patch}")
139+
140+
commands = ["git status", "git apply tmp_patch.txt", "rm -f tmp_patch.txt"]
141+
for cmd in commands:
142+
self.logger.debug(f"Executing command: {cmd}")
143+
out = assert_zero_exit_code(self.environment.execute(cmd), logger=self.logger)
144+
self.logger.debug(out)
145145

146146
# --- Helper methods ---
147147

0 commit comments

Comments
 (0)