Skip to content

Commit 07ad9d3

Browse files
fix: fetch base_commit in shallow clone to enable git reset
The shallow clone only fetches the latest commit, but the setup scripts need access to both env_setup_commit (reference_commit) and base_commit for the git reset operations. - Commit0Spec: Fetch both env_setup_commit and base_commit before removing remote - SWEBenchSpec: Fetch base_commit needed for eval script reset Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 157a4ff commit 07ad9d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

commit0/harness/spec.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def make_repo_script_list(self) -> list[str]:
119119
f"git clone --depth 1 -o origin https://github.com/{repo} {self.repo_directory}",
120120
f"chmod -R 777 {self.repo_directory}", # So nonroot user can run tests
121121
f"cd {self.repo_directory}",
122-
f"git fetch --depth 1 origin {env_setup_commit}",
122+
# Fetch both commits needed: env_setup_commit for setup and base_commit for later reset
123+
f"git fetch --depth 1 origin {env_setup_commit} {base_commit}",
123124
f"git reset --hard {env_setup_commit}",
124125
# Remove the remote so the agent won't see newer commits.
125126
"git remote remove origin",
@@ -220,12 +221,15 @@ def make_repo_script_list(self) -> list[str]:
220221
if version < 7:
221222
specs["python"] = 3.7
222223

224+
base_commit = self.instance["base_commit"]
223225
setup_commands = [
224226
# Use --depth 1 for shallow clone to prevent agents from accessing
225227
# git history and exploiting it to retrieve original implementations
226228
f"git clone --depth 1 -o origin https://github.com/{repo} {self.repo_directory}",
227229
f"chmod -R 777 {self.repo_directory}", # So nonroot user can run tests
228230
f"cd {self.repo_directory}",
231+
# Fetch base_commit needed for eval script reset
232+
f"git fetch --depth 1 origin {base_commit}",
229233
# Remove the remote so the agent won't see newer commits.
230234
"git remote remove origin",
231235
f"uv venv --python {specs['python']}",

0 commit comments

Comments
 (0)