fix: strip .git suffix when parsing github repo url (#1442)
_parse_gh_repo_url left a trailing .git on the repo name, so a clone URL like https://github.com/SWE-agent/SWE-agent.git produced repo_name SWE-agent__SWE-agent.git, polluting instance ids and output dir names. Strip it off the repo group and extend the test.
This commit is contained in:
@@ -82,9 +82,8 @@ def _parse_gh_repo_url(repo_url: str) -> tuple[str, str]:
|
||||
if not match:
|
||||
msg = f"Invalid GitHub issue URL: {repo_url}"
|
||||
raise InvalidGithubURL(msg)
|
||||
res = match.groups()
|
||||
assert len(res) == 2
|
||||
return tuple(res) # type: ignore
|
||||
owner, repo = match.groups()
|
||||
return owner, repo.removesuffix(".git")
|
||||
|
||||
|
||||
def _get_gh_issue_data(issue_url: str, *, token: str = ""):
|
||||
|
||||
@@ -39,6 +39,8 @@ def test_parse_gh_repo_url():
|
||||
assert _parse_gh_repo_url("github.com/SWE-agent/SWE-agent") == ("SWE-agent", "SWE-agent")
|
||||
assert _parse_gh_repo_url("github.com/SWE-agent/SWE-agent/asdfjsdfg") == ("SWE-agent", "SWE-agent")
|
||||
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")
|
||||
|
||||
|
||||
def test_parse_gh_repo_url_fails():
|
||||
|
||||
Reference in New Issue
Block a user