aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula_installer.rb4
-rw-r--r--Library/Homebrew/tab.rb35
2 files changed, 38 insertions, 1 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index e30b4f98a..537cbd317 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -248,9 +248,11 @@ class FormulaInstaller
# Did the user actually pass the formula this installer is considering on
# the command line?
def explicitly_requested?; ARGV.formulae.include? f end
+ previous_install = Tab.for_formula f
args = ARGV.clone
- args.uniq! # Just in case someone was playing around...
+ args.concat previous_install.used_options
+ args.uniq! # Just in case some dupes were added
%w[--HEAD --verbose -v --debug -d --interactive -i].each {|f| args.delete f} unless explicitly_requested?
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 15f8522c1..9eb9a34a9 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -20,6 +20,41 @@ class Tab < OpenStruct
:tabfile => f.prefix + 'INSTALL_RECEIPT.json'
end
+ def self.from_file path
+ tab = Tab.new MultiJson.decode(open(path).read)
+ tab.tabfile = path
+
+ return tab
+ end
+
+ def self.for_formula f
+ f = Formula.factory f unless f.kind_of? Formula
+ path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json'
+
+ if path.exist?
+ self.from_file path
+ else
+ # Really should bail out with an error if a formula was not installed
+ # with a Tab. However, there will be lots of legacy installs that have no
+ # receipt---so we fabricate one that claims the formula was installed with
+ # no options.
+ #
+ # TODO:
+ # This isn't the best behavior---perhaps a future version of Homebrew can
+ # treat missing Tabs as errors.
+ Tab.new :used_options => [],
+ :unused_options => f.options.map { |o, _| o}
+ end
+ end
+
+ def installed_with? opt
+ used_options.include? opt
+ end
+
+ def options
+ used_options + unused_options
+ end
+
def to_json
MultiJson.encode({
:used_options => used_options,