Skip to content

Commit

Permalink
add support for ssh protocol
Browse files Browse the repository at this point in the history
(cherry picked from commit d3b54bbf690c4707a52b9eaec31f24701fb7e6c7)
(cherry picked from commit c46d13e30f4d32daea3eb9a9b28091afcadd7446)
(cherry picked from commit 1b0926a)
  • Loading branch information
Evizero authored and KristofferC committed Feb 11, 2019
1 parent 285fc25 commit 464182e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
9 changes: 7 additions & 2 deletions stdlib/Pkg/src/GitTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ setprotocol!(proto::Union{Nothing, AbstractString}=nothing) = GIT_PROTOCOL[] = p
# TODO: extend this to more urls
function normalize_url(url::AbstractString)
m = match(GITHUB_REGEX, url)
(m === nothing || GIT_PROTOCOL[] === nothing) ?
url : "$(GIT_PROTOCOL[])://github.com/$(m.captures[1]).git"
if m === nothing || GIT_PROTOCOL[] === nothing
url
elseif GIT_PROTOCOL[] == "ssh"
"ssh://[email protected]/$(m.captures[1]).git"
else
"$(GIT_PROTOCOL[])://github.com/$(m.captures[1]).git"
end
end

function clone(url, source_path; header=nothing, kwargs...)
Expand Down
17 changes: 17 additions & 0 deletions stdlib/Pkg/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,23 @@ temp_pkg_dir() do project_path
end
end
end
mktempdir() do devdir
withenv("JULIA_PKG_DEVDIR" => devdir) do
try
https_url = "https://github.com/JuliaLang/Example.jl.git"
ssh_url = "ssh://[email protected]/JuliaLang/Example.jl.git"
@test Pkg.GitTools.normalize_url(https_url) == https_url
Pkg.setprotocol!("ssh")
@test Pkg.GitTools.normalize_url(https_url) == ssh_url
# TODO: figure out how to test this without
# having to deploy a ssh key on github
#Pkg.develop("Example")
#@test isinstalled(TEST_PKG)
finally
Pkg.setprotocol!()
end
end
end
end

@testset "check logging" begin
Expand Down

0 comments on commit 464182e

Please sign in to comment.