From a232e3a791ac97b3ac45ab9d6b34e5c65a49b943 Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Fri, 24 Aug 2018 11:38:14 -0400 Subject: [PATCH] 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. --- Library/Homebrew/dev-cmd/extract.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 9ebec61354..9d19a2ffc6 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -16,10 +16,18 @@ require "tap" class BottleSpecification def method_missing(*); end + + def respond_to_missing?(*) + true + end end class Module def method_missing(*); end + + def respond_to_missing?(*) + true + end end class DependencyCollector @@ -75,6 +83,9 @@ module Homebrew end 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) + elsif File.exist?(file) + version = Formulary.factory(file).version + result = File.read(file) else rev = Git.last_revision_commit_of_file(repo, file) version = formula_at_revision(repo, name, file, rev).version