Skip to content

Commit

Permalink
Support SSH urls for the registry (#362)
Browse files Browse the repository at this point in the history
This lets you use an SSH url for your registry repo when you configure the WebUI server.
  • Loading branch information
nkottary authored Jan 21, 2022
1 parent 9d58915 commit 44dc265
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/webui/WebUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function init_registry()
repo = @gf get_repo(forge, owner, name)
repo === nothing && error("Registry lookup failed")

clone = get(CONFIG, "registry_clone_url", url)
fork_url = get(CONFIG, "registry_fork_url", clone)
clone = remove_ssh_prefix(get(CONFIG, "registry_clone_url", url))
fork_url = remove_ssh_prefix(get(CONFIG, "registry_fork_url", clone))
fork_owner, fork_name = splitrepo(fork_url)
fork_repo = @gf get_repo(forge, fork_owner, fork_name)
fork_repo === nothing && error("Registry fork lookup failed")
Expand Down
7 changes: 6 additions & 1 deletion src/webui/gitutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ end

# Split a repo path into its owner and name.
function splitrepo(url::AbstractString)
pieces = split(HTTP.URI(url).path, "/"; keepempty=false)
if startswith(url, "https://") || startswith(url, "http://")
pieces = split(HTTP.URI(url).path, "/"; keepempty=false)
else
pieces = split(split(url, ":")[end], "/")
end

owner = join(pieces[1:end-1], "/")
name = pieces[end]
return owner, name
Expand Down
2 changes: 2 additions & 0 deletions src/webui/webutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ function parseform(s::AbstractString)
pairs = split(replace(s, "+" => " "), "&")
return Dict(map(p -> map(strip HTTP.unescapeuri, split(p, "=")), pairs))
end

remove_ssh_prefix(s::AbstractString) = startswith(s, "ssh://") ? s[length("ssh://")+1:end] : s

0 comments on commit 44dc265

Please sign in to comment.