From aa67d8f6f192437439db48039f0d1c110e7ea7ca Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Sat, 14 Sep 2013 15:13:04 -0400 Subject: [PATCH] Pkg.tag: read requires from the given commit, not head. --- base/pkg.jl | 15 +++++++++++---- base/pkg/reqs.jl | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/base/pkg.jl b/base/pkg.jl index b3ad725eb4a43..d3e0f13a26625 100644 --- a/base/pkg.jl +++ b/base/pkg.jl @@ -338,14 +338,21 @@ tag(pkg::String, ver::Union(Symbol,VersionNumber)=:bump; registered || return try info("Writing METADATA for $pkg v$ver") - reqs = Reqs.parse(joinpath(pkg,"REQUIRE")) + reqs = Reqs.parse(Git.cmd(`cat-file blob $commit:REQUIRE`,dir=pkg)) cd("METADATA") do Git.transact() do d = joinpath(pkg,"versions",string(ver)) mkpath(d) - open(io->println(io,commit), joinpath(d,"sha1"), "w") - isempty(reqs) || Reqs.write(joinpath(d,"requires"), reqs) - Git.run(`add $d`) + sha1file = joinpath(d,"sha1") + open(io->println(io,commit), sha1file, "w") + Git.run(`add $sha1file`) + reqsfile = joinpath(d,"requires") + if isempty(reqs) + ispath(reqsfile) && Git.run(`rm -f -q $reqsfile`) + else + Reqs.write(reqsfile,reqs) + Git.run(`add $reqsfile`) + end end end catch diff --git a/base/pkg/reqs.jl b/base/pkg/reqs.jl index b3b7f020ddd68..9c07e11a44784 100644 --- a/base/pkg/reqs.jl +++ b/base/pkg/reqs.jl @@ -37,9 +37,9 @@ end # general machinery for parsing REQUIRE files -function read(io::IO) +function read(readable::Union(IO,Base.AbstractCmd)) lines = Line[] - for line in eachline(io) + for line in eachline(readable) line = chomp(line) push!(lines, ismatch(r"^\s*(?:#|$)", line) ? Comment(line) : Requirement(line)) end