Skip to content

Commit

Permalink
test and fix libgit2 download of registered packages (#218)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8ce1240fc2080eabff022a05bc5b17ed03c4c2b5)
  • Loading branch information
KristofferC committed Mar 23, 2018
1 parent 7eb5d44 commit 2f3e02d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions stdlib/Pkg3/src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ end

const refspecs = ["+refs/*:refs/remotes/cache/*"]
function install_git(
ctx::Context,
uuid::UUID,
name::String,
hash::SHA1,
Expand All @@ -403,8 +404,7 @@ function install_git(
LibGit2.fetch(repo, remoteurl=url, refspecs=refspecs)
end
tree = try
with(LibGit2.GitObject, repo, git_hash) do g
end
LibGit2.GitObject(repo, git_hash)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
error("$name: git object $(string(hash)) could not be found")
Expand All @@ -417,7 +417,7 @@ function install_git(
target_directory = Base.unsafe_convert(Cstring, version_path)
)
LibGit2.checkout_tree(repo, tree, options=opts)
close(repo); close(tree); close(opts); close(git_hash)
close(repo); close(tree)
return
end

Expand Down Expand Up @@ -493,7 +493,7 @@ function apply_versions(ctx::Context, pkgs::Vector{PackageSpec})::Vector{UUID}
for (pkg, path) in missed_packages
uuid = pkg.uuid
if !ctx.preview
install_git(pkg.uuid, pkg.name, hashes[uuid], urls[uuid], pkg.version::VersionNumber, path)
install_git(ctx, pkg.uuid, pkg.name, hashes[uuid], urls[uuid], pkg.version::VersionNumber, path)
end
vstr = pkg.version != nothing ? "v$(pkg.version)" : "[$h]"
@info "Installed $(rpad(pkg.name * " ", max_name + 2, "")) $vstr"
Expand Down
9 changes: 8 additions & 1 deletion stdlib/Pkg3/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include("utils.jl")
const TEST_PKG = (name = "Example", uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a"))

temp_pkg_dir() do project_path

@testset "simple add and remove with preview" begin
Pkg3.init(project_path)
Pkg3.add(TEST_PKG.name; preview = true)
Expand Down Expand Up @@ -146,6 +145,14 @@ temp_pkg_dir() do project_path
Pkg3.rm(TEST_PKG.name)
end

temp_pkg_dir() do project_path
@testset "libgit2 downloads" begin
Pkg3.add(TEST_PKG.name; use_libgit2_for_all_downloads=true)
@test haskey(Pkg3.installed(), TEST_PKG.name)
Pkg3.rm(TEST_PKG.name)
end
end

include("repl.jl")

end # module
1 change: 0 additions & 1 deletion stdlib/Pkg3/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ temp_pkg_dir() do project_path; cd(project_path) do; mktempdir() do tmp_pkg_path
Pkg3.REPLMode.pkgstr("add $p2#$c")
end

# TODO cleanup
mktempdir() do tmp_dev_dir
withenv("JULIA_PKG_DEVDIR" => tmp_dev_dir) do
pkg"develop Example"
Expand Down

0 comments on commit 2f3e02d

Please sign in to comment.