fix: strip query/fragment from repo URLs; correct parse error text (#1463)
* fix: strip query/fragment from repo URLs; correct parse error text Co-authored-by: Cursor <cursoragent@cursor.com> * ci: pin docs deploy to Python 3.12 Co-authored-by: Cursor <cursoragent@cursor.com> * fix: pin ghapi<2 so sync GhApi calls do not return coroutines Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -29,7 +29,7 @@ jobs:
|
||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: 3.x
|
||||
python-version: "3.12"
|
||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||
- uses: actions/cache@v6
|
||||
with:
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -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 = ""):
|
||||
|
||||
@@ -41,10 +41,13 @@ def test_parse_gh_repo_url():
|
||||
assert _parse_gh_repo_url("git@github.com/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/")
|
||||
|
||||
Reference in New Issue
Block a user