Skip to content

Commit b3e7296

Browse files
Remove parse_plugin_source/get_cache_path, slim plugin tests
- Remove parse_plugin_source and get_cache_path from plugin/fetch.py; callers should use extensions.fetch directly. - Slim test_plugin_fetch.py from 1038 to 100 lines: keep only PluginFetchError wrapping, DEFAULT_CACHE_DIR, and Plugin.fetch() tests. - Move git infrastructure tests (clone, update, checkout, locking, GitHelper errors, get_default_branch) to tests/sdk/git/test_cached_repo.py. - Update test_installed_plugins.py to import from extensions.fetch. Co-authored-by: openhands <openhands@all-hands.dev>
1 parent e099061 commit b3e7296

File tree

4 files changed

+537
-1052
lines changed

4 files changed

+537
-1052
lines changed

openhands-sdk/openhands/sdk/plugin/fetch.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from openhands.sdk.extensions.fetch import (
1313
ExtensionFetchError,
1414
fetch_with_resolution as _ext_fetch_with_resolution,
15-
get_cache_path as _ext_get_cache_path,
16-
parse_extension_source,
1715
)
1816
from openhands.sdk.git.cached_repo import GitHelper
1917

@@ -25,54 +23,6 @@ class PluginFetchError(Exception):
2523
"""Raised when fetching a plugin fails."""
2624

2725

28-
def parse_plugin_source(source: str) -> tuple[str, str]:
29-
"""Parse plugin source into (type, url).
30-
31-
Args:
32-
source: Plugin source string. Can be:
33-
- "github:owner/repo" - GitHub repository shorthand
34-
- "https://github.com/owner/repo.git" - Full git URL
35-
- "git@github.com:owner/repo.git" - SSH git URL
36-
- "/local/path" - Local path
37-
38-
Returns:
39-
Tuple of (source_type, normalized_url) where source_type is one of:
40-
- "github": GitHub repository
41-
- "git": Any git URL
42-
- "local": Local filesystem path
43-
44-
Examples:
45-
>>> parse_plugin_source("github:owner/repo")
46-
("github", "https://github.com/owner/repo.git")
47-
>>> parse_plugin_source("https://gitlab.com/org/repo.git")
48-
("git", "https://gitlab.com/org/repo.git")
49-
>>> parse_plugin_source("/local/path")
50-
("local", "/local/path")
51-
"""
52-
try:
53-
source_type, url = parse_extension_source(source)
54-
except ExtensionFetchError as exc:
55-
raise PluginFetchError(str(exc).replace("extension", "plugin")) from exc
56-
return (source_type.value, url)
57-
58-
59-
def get_cache_path(source: str, cache_dir: Path | None = None) -> Path:
60-
"""Get the cache path for a plugin source.
61-
62-
Creates a deterministic path based on a hash of the source URL.
63-
64-
Args:
65-
source: The plugin source (URL or path).
66-
cache_dir: Base cache directory. Defaults to ~/.openhands/cache/plugins/
67-
68-
Returns:
69-
Path where the plugin should be cached.
70-
"""
71-
return _ext_get_cache_path(
72-
source, cache_dir if cache_dir is not None else DEFAULT_CACHE_DIR
73-
)
74-
75-
7626
def fetch_plugin(
7727
source: str,
7828
cache_dir: Path | None = None,

0 commit comments

Comments
 (0)