Add compat with Julia 1.4
This commit is contained in:
parent
5aa0a87c35
commit
0fcbaa83bf
@ -80,12 +80,8 @@ function posthook(p::Git, ::Template, pkg_dir::AbstractString)
|
|||||||
LibGit2.with(GitRepo(pkg_dir)) do repo
|
LibGit2.with(GitRepo(pkg_dir)) do repo
|
||||||
LibGit2.add!(repo, ".")
|
LibGit2.add!(repo, ".")
|
||||||
msg = "Files generated by PkgTemplates"
|
msg = "Files generated by PkgTemplates"
|
||||||
# TODO: Newer versions of Julia will not have Pkg.installed.
|
v = version_of("PkgTemplates")
|
||||||
installed = Pkg.installed()
|
v === nothing || (msg *= "\n\nPkgTemplates version: $v")
|
||||||
if haskey(installed, "PkgTemplates")
|
|
||||||
ver = string(installed["PkgTemplates"])
|
|
||||||
msg *= "\n\nPkgTemplates version: $ver"
|
|
||||||
end
|
|
||||||
commit(p, repo, pkg_dir, msg)
|
commit(p, repo, pkg_dir, msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,3 +95,14 @@ function commit(p::Git, repo::GitRepo, pkg_dir::AbstractString, msg::AbstractStr
|
|||||||
end
|
end
|
||||||
|
|
||||||
needs_username(::Git) = true
|
needs_username(::Git) = true
|
||||||
|
|
||||||
|
if isdefined(Pkg, :dependencies)
|
||||||
|
function version_of(pkg::AbstractString)
|
||||||
|
for p in values(Pkg.dependencies())
|
||||||
|
p.name == pkg && return p.version
|
||||||
|
end
|
||||||
|
return nothing
|
||||||
|
end
|
||||||
|
else
|
||||||
|
version_of(pkg::AbstractString) = get(Pkg.installed(), pkg, nothing)
|
||||||
|
end
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
@testset "Adds version to commit message" begin
|
@testset "Adds version to commit message" begin
|
||||||
# We're careful to avoid a Pkg.update as it triggers Cassette#130.
|
# We're careful to avoid a Pkg.update as it triggers Cassette#130.
|
||||||
t = tpl(; disable_defaults=[Tests], plugins=[Git()])
|
t = tpl(; disable_defaults=[Tests], plugins=[Git()])
|
||||||
mock(Pkg.installed => () -> Dict("PkgTemplates" => v"1.2.3")) do _pi
|
mock(PT.version_of => _p -> v"1.2.3") do _i
|
||||||
with_pkg(t) do pkg
|
with_pkg(t) do pkg
|
||||||
pkg_dir = joinpath(t.dir, pkg)
|
pkg_dir = joinpath(t.dir, pkg)
|
||||||
LibGit2.with(GitRepo(pkg_dir)) do repo
|
LibGit2.with(GitRepo(pkg_dir)) do repo
|
||||||
|
@ -6,7 +6,7 @@ using Random: Random
|
|||||||
using Test: @test, @testset, @test_throws
|
using Test: @test, @testset, @test_throws
|
||||||
|
|
||||||
using ReferenceTests: @test_reference
|
using ReferenceTests: @test_reference
|
||||||
using SimpleMock: Mock, mock
|
using SimpleMock: mock
|
||||||
using Suppressor: @suppress
|
using Suppressor: @suppress
|
||||||
|
|
||||||
using PkgTemplates
|
using PkgTemplates
|
||||||
@ -30,7 +30,9 @@ function with_pkg(f::Function, t::Template, pkg::AbstractString=pkgname())
|
|||||||
try
|
try
|
||||||
f(pkg)
|
f(pkg)
|
||||||
finally
|
finally
|
||||||
haskey(Pkg.installed(), pkg) && @suppress Pkg.rm(pkg)
|
# On 1.4, this sometimes won't work, but the error is that the package isn't installed.
|
||||||
|
# We're going to delete the package directory anyways, so just ignore any errors.
|
||||||
|
PT.version_of(pkg) === nothing || try @suppress Pkg.rm(pkg) catch; end
|
||||||
rm(joinpath(t.dir, pkg); recursive=true, force=true)
|
rm(joinpath(t.dir, pkg); recursive=true, force=true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user