extract: fix corner case

If the formula to be retrieved was just version-bumped in the most
recent commit (HEAD), we would've ended up grabbing the second-most
recent version.

Instead, if the file already exists in tree at the current commit,
just construct the formula from that to get the version (for naming
purposes) and copy the file outright to its new location.
This commit is contained in:
Caleb Xu 2018-08-24 11:38:14 -04:00
parent bc551d5ed1
commit a232e3a791

View File

@ -16,10 +16,18 @@ require "tap"
class BottleSpecification class BottleSpecification
def method_missing(*); end def method_missing(*); end
def respond_to_missing?(*)
true
end
end end
class Module class Module
def method_missing(*); end def method_missing(*); end
def respond_to_missing?(*)
true
end
end end
class DependencyCollector class DependencyCollector
@ -75,6 +83,9 @@ module Homebrew
end end
odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil? odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil?
result = Git.last_revision_of_file(repo, file, before_commit: rev) result = Git.last_revision_of_file(repo, file, before_commit: rev)
elsif File.exist?(file)
version = Formulary.factory(file).version
result = File.read(file)
else else
rev = Git.last_revision_commit_of_file(repo, file) rev = Git.last_revision_commit_of_file(repo, file)
version = formula_at_revision(repo, name, file, rev).version version = formula_at_revision(repo, name, file, rev).version