Skip to content

Commit

Permalink
Merge #702 #716
Browse files Browse the repository at this point in the history
702: add support for "ssh" protocol r=KristofferC a=Evizero

This is a minimalistic change to support the use of `Pkg.setprotocol!("ssh")` to fix #653.

My naive reasoning here is that since "github" is hardcoded anyway, one might as well adapt the URL string for when using the ~~"git"~~ "ssh" protocol.

Note though that this only works if the repo has not been cloned into ".julia/clones"  already using the defaul setting (i.e. https). If that is the case then `dev Example` will say

```
  Updating git-repo `[email protected]:JuliaLang/Example.jl.git`
```

while `git remote -v` in that new dev-ed directory will still show `origin` using the `https` version.
Not sure where to fix that.

716: Update project.toml compat example r=KristofferC a=mcmcgrath13

Adding this PR here instead of [JuliaLang](JuliaLang/julia#28947) per @KristofferC

Co-authored-by: Christof Stocker <[email protected]>
Co-authored-by: Mary McGrath <[email protected]>
  • Loading branch information
3 people committed Sep 17, 2018
3 parents 7bf7e49 + d3b54bb + 9673615 commit a729bc1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ Compatibility for a dependency is entered in the `Project.toml` file as for exam

```toml
[compat]
julia = "1.0"
Example = "0.4.3"
```

Expand Down
9 changes: 7 additions & 2 deletions 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 test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,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 a729bc1

Please sign in to comment.