Skip to content

Commit

Permalink
possibly fix #101
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Mar 19, 2017
1 parent 0f8f2b4 commit 25f2aaf
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ function publish(branch::AbstractString, prbranch::AbstractString="")
m !== nothing && ismatch(Base.VERSION_REGEX, m.captures[2]) || continue
pkg, ver = m.captures; ver = convert(VersionNumber,ver)
sha1 = readchomp(joinpath(metapath,path))
old = LibGit2.cat(repo, LibGit2.GitBlob, "origin/$branch:$path")
old !== nothing && old != sha1 && throw(PkgError("$pkg v$ver SHA1 changed in METADATA – refusing to publish"))
if VERSION < v"0.6-"
old = LibGit2.cat(repo, LibGit2.GitBlob, "origin/$branch:$path")
old !== nothing && old != sha1 && throw(PkgError("$pkg v$ver SHA1 changed in METADATA – refusing to publish"))
else
try
old = LibGit2.content(LibGit2.GitBlob(repo, "origin/$branch:$path"))
old != sha1 && throw(PkgError("$pkg v$ver SHA1 changed in METADATA – refusing to publish"))
catch e
isa(e, LibGit2.GitError) || rethrow(e)
end
end
with(GitRepo, PkgDev.dir(pkg)) do pkg_repo
tag_name = "v$ver"
tag_commit = LibGit2.revparseid(pkg_repo, "$(tag_name)^{commit}")
Expand Down Expand Up @@ -123,10 +132,20 @@ end

function write_tag_metadata(repo::GitRepo, pkg::AbstractString, ver::VersionNumber, commit::AbstractString, force::Bool=false)
pkgdir = PkgDev.dir(pkg)
content = with(GitRepo, pkgdir) do pkg_repo
LibGit2.cat(pkg_repo, LibGit2.GitBlob, "$commit:REQUIRE")
reqs = with(GitRepo, pkgdir) do pkg_repo
if VERSION < v"0.6-"
content = LibGit2.cat(pkg_repo, LibGit2.GitBlob, "$commit:REQUIRE")
content !== nothing ? Reqs.read(split(content, '\n', keep=false)) : Reqs.Line[]
else
try
content = LibGit2.content(LibGit2.GitBlob(pkg_repo, "$commit:REQUIRE"))
Reqs.read(split(content, '\n', keep=false))
catch e
isa(e,GitError) || rethrow(e)
Reqs.Line[]
end
end
end
reqs = content !== nothing ? Reqs.read(split(content, '\n', keep=false)) : Reqs.Line[]
cd(Pkg.dir("METADATA")) do
# work around julia#18724 and PkgDev#28
d = join([pkg, "versions", string(ver)], '/')
Expand Down

0 comments on commit 25f2aaf

Please sign in to comment.