Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openhands-sdk/openhands/sdk/extensions/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def parse_extension_source(source: str) -> tuple[SourceType, str]:
# GitHub shorthand: github:owner/repo[/subpath]
if source.startswith("github:"):
repo, _ = _split_github_shorthand(source)
url = f"https://github.com/{repo}.git"
# The shorthand may already name the repository file; add the suffix
# only when it is missing.
url = f"https://github.com/{repo.removesuffix('.git')}.git"
return (SourceType.GITHUB, url)

# Git URLs: detect by protocol/scheme rather than enumerating providers
Expand Down
9 changes: 9 additions & 0 deletions openhands-sdk/openhands/sdk/git/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ def is_git_url(source: str) -> bool:
if re.match(r"^[\w.-]+@[\w.-]+:", source):
return True

# SSH scheme, with or without a user and port
if source.startswith("ssh://"):
return True

# Git protocol
if source.startswith("git://"):
return True
Expand Down Expand Up @@ -593,7 +597,12 @@ def normalize_git_url(url: str) -> str:
"https://dev.azure.com/org/project/_git/repo"
"""
if url.startswith(("https://", "http://")) and not url.endswith(".git"):
# Strip the trailing slash before the suffix check, so a URL that
# already names a repository (``repo.git/``) does not gain a second
# suffix from the append below.
url = url.rstrip("/")
if url.endswith(".git"):
return url
# Azure DevOps resolves ``<repo>.git`` as a different, missing repo.
if "/_git/" in urlparse(url).path:
return url
Expand Down
19 changes: 19 additions & 0 deletions tests/sdk/extensions/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ def test_parse_ssh_with_custom_user():
assert url == ssh_url


def test_parse_ssh_scheme_url():
ssh_url = "ssh://git@git.example.com:2222/org/repo.git"
assert parse_extension_source(ssh_url) == (SourceType.GIT, ssh_url)


def test_parse_github_shorthand_with_git_suffix():
assert parse_extension_source("github:owner/repo.git") == (
SourceType.GITHUB,
"https://github.com/owner/repo.git",
)


def test_parse_https_url_with_git_suffix_and_trailing_slash():
assert parse_extension_source("https://github.com/owner/repo.git/") == (
SourceType.GIT,
"https://github.com/owner/repo.git",
)


def test_parse_relative_path_with_slash():
source_type, url = parse_extension_source("extensions/my-ext")
assert source_type == SourceType.LOCAL
Expand Down
Loading