SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
CI: Disable check for dirty repo during testing
Kilian Lieretfd71d093f9f4
diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex d594f674..2c908235 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -828,7 +828,7 @@ class InstanceBuilder:except InvalidGitRepositoryError as e:msg = f"Could not find git repository at {path=}."raise ValueError(msg) from e- if repo.is_dirty():+ if repo.is_dirty() and "PYTEST_CURRENT_TEST" not in os.environ:msg = f"Local git repository {path} is dirty. Please commit or stash changes."raise ValueError(msg)self.args["base_commit"] = repo.head.object.hexshadiff --git a/tests/test_replay.py b/tests/test_replay.pyindex c45c15a0..509bb1de 100644--- a/tests/test_replay.py+++ b/tests/test_replay.py@@ -1,7 +1,9 @@from __future__ import annotations+import osimport subprocessfrom pathlib import Path+from unittest import mockimport pytest@@ -146,5 +148,9 @@ def test_exception_replay_local_dirty(swe_agent_test_repo_clone, swe_agent_test_"--raise_exceptions",]args, remaining_args = get_args(run_cmd)- with pytest.raises(ValueError, match=".*dirty.*"):- main(**vars(args), forward_args=remaining_args)+ # In the code, we exclude testing from this check because of tests hosted in the repo+ # so here we pretend we're not in a test+ modified_environ = {k: v for k, v in os.environ.items() if k != "PYTEST_CURRENT_TEST"}+ with mock.patch.dict(os.environ, modified_environ, clear=True):+ with pytest.raises(ValueError, match=".*dirty.*"):+ main(**vars(args), forward_args=remaining_args)