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]
fix: strip query/fragment from repo URLs; correct parse error text (#1463)
Taksh Kothari1dd50afb5877
diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yamlindex 72bfaa20..7931fa80 100644--- a/.github/workflows/build-docs.yaml+++ b/.github/workflows/build-docs.yaml@@ -29,7 +29,7 @@ jobs:git config user.email 41898282+github-actions[bot]@users.noreply.github.com- uses: actions/setup-python@v6with:- python-version: 3.x+ python-version: "3.12"- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV- uses: actions/cache@v6with:diff --git a/pyproject.toml b/pyproject.tomlindex daad47ee..f17efb69 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -56,7 +56,7 @@ dependencies = ["pydantic_settings","litellm>=1.44.12,!=1.82.7,!=1.82.8","GitPython",- "ghapi",+ "ghapi>=1.0.0,<2","swe-rex>=1.4.0","tabulate","textual>=1.0.0",diff --git a/sweagent/utils/github.py b/sweagent/utils/github.pyindex 425fae87..674b10e9 100644--- a/sweagent/utils/github.py+++ b/sweagent/utils/github.py@@ -80,10 +80,10 @@ def _parse_gh_repo_url(repo_url: str) -> tuple[str, str]:"""match = GITHUB_REPO_URL_PATTERN.search(repo_url)if not match:- msg = f"Invalid GitHub issue URL: {repo_url}"+ msg = f"Invalid GitHub repository URL: {repo_url}"raise InvalidGithubURL(msg)owner, repo = match.groups()- return owner, repo.removesuffix(".git")+ return owner, repo.split("?", 1)[0].split("#", 1)[0].removesuffix(".git")def _get_gh_issue_data(issue_url: str, *, token: str = ""):diff --git a/tests/test_env_utils.py b/tests/test_env_utils.pyindex c0cc2db5..853d0199 100644--- a/tests/test_env_utils.py+++ b/tests/test_env_utils.py@@ -41,10 +41,13 @@ def test_parse_gh_repo_url():assert _parse_gh_repo_url("[email protected]/SWE-agent/SWE-agent/asdfjsdfg") == ("SWE-agent", "SWE-agent")assert _parse_gh_repo_url("https://github.com/SWE-agent/SWE-agent.git") == ("SWE-agent", "SWE-agent")assert _parse_gh_repo_url("github.com/SWE-agent/SWE-agent.git") == ("SWE-agent", "SWE-agent")+ assert _parse_gh_repo_url("https://github.com/SWE-agent/SWE-agent?ref=main") == ("SWE-agent", "SWE-agent")+ assert _parse_gh_repo_url("https://github.com/SWE-agent/SWE-agent#readme") == ("SWE-agent", "SWE-agent")+ assert _parse_gh_repo_url("https://github.com/SWE-agent/SWE-agent.git?ref=main") == ("SWE-agent", "SWE-agent")def test_parse_gh_repo_url_fails():- with pytest.raises(InvalidGithubURL):+ with pytest.raises(InvalidGithubURL, match="repository URL"):_parse_gh_repo_url("adfkj;lasdfl;kj")with pytest.raises(InvalidGithubURL):_parse_gh_repo_url("github.com/")