Skip to content

Commit b7abd36

Browse files
committed
Support accessing remote registries via ssh
The URL has to be given as "ssh://[user@]host.xz[:port]/path/to/repo.git" rather than the shorter version "[user@]host.xz:path/to/repo.git"
1 parent c035442 commit b7abd36

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

shpc/main/registry/provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Provider:
3333
"""
3434

3535
def __init__(self, source, *args, **kwargs):
36-
if not (source.startswith("https://") or os.path.exists(source)):
36+
if not (source.startswith("https://") or source.startswith("ssh://") or os.path.exists(source)):
3737
raise ValueError(
3838
"Registry source must exist on the filesystem or be given as https://."
3939
)
@@ -44,7 +44,7 @@ def exists(self, name):
4444

4545
@property
4646
def is_filesystem_registry(self):
47-
return not self.source.startswith("http") and os.path.exists(self.source)
47+
return not (self.source.startswith("http") or self.source.startswith("ssh")) and os.path.exists(self.source)
4848

4949
@property
5050
def name(self):

shpc/main/registry/remote.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self, *args, **kwargs):
104104

105105
@classmethod
106106
def matches(cls, source):
107-
return cls.provider_name in source and source.startswith("http")
107+
return cls.provider_name in source and (source.startswith("http") or source.startswith("ssh"))
108108

109109
@property
110110
def source_url(self):
@@ -190,6 +190,8 @@ def _update_cache(self, force=False):
190190
if self._cache and not force:
191191
return
192192

193+
if self.source.startswith("ssh"):
194+
return self._update_clone_cache()
193195
# Check for exposed library API on GitHub or GitLab pages
194196
response = requests.get(self.web_url)
195197
if response.status_code != 200:

0 commit comments

Comments
 (0)