diff --git a/src/api.jl b/src/api.jl index 818fb6f..510ef53 100644 --- a/src/api.jl +++ b/src/api.jl @@ -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) @@ -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", diff --git a/src/utils.jl b/src/utils.jl index 6727555..e1baabf 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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"],