Skip to content

Commit

Permalink
Don't prefer HTTPs repository URL by default
Browse files Browse the repository at this point in the history
The one used in Git repository (e.g., SSH) works better with
unregistered packages.
  • Loading branch information
tkf committed Aug 26, 2019
1 parent 9c57c23 commit 124b976
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,13 @@ in `Manifest.toml` file checked in its repository (e.g.,
- `project::Union{Nothing, AbstractString} = nothing`: Project
in which the package is installed. `nothing` (default) means
the current activated project.
- `prefer_https::Bool = false`: Prefer HTTPS repository URL rather
than the one used in Git repository.
"""
function add(
name::AbstractString;
project::Union{Nothing, AbstractString} = nothing,
prefer_https::Bool = false,
)
path = joinpath(expanduser("~/.julia/dev"), name) # TODO: don't
@assert isdir(path)
Expand All @@ -177,7 +180,7 @@ function add(
return (rank, r)
end
manifestfile, = sort(find_manifests(path), by=sortkey)
spec = pkgspecof(path)
spec = pkgspecof(path; prefer_https=prefer_https)
deps = keys(get(
TOML.parsefile(projecttomlpath(path)),
"deps",
Expand Down
8 changes: 6 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ function pkgat(path::AbstractString) :: PkgId
return PkgId(UUID(prj["uuid"]), prj["name"])
end

function pkgspecof(path::AbstractString)
function pkgspecof(path::AbstractString; prefer_https=false)
prj = TOML.parsefile(projecttomlpath(path))
url = vcslinktoroot(path=path)
if prefer_https
url = vcslinktoroot(path=path)
else
url = strip(read(git_cmd(`config remote.origin.url`, path), String))
end
tree_sha = strip(read(git_cmd(`rev-parse "HEAD^{tree}"`, path), String))
spec = Pkg.PackageSpec(
name = prj["name"],
Expand Down

0 comments on commit 124b976

Please sign in to comment.