diff options
| author | Jack Nagel | 2013-12-09 21:10:32 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-12-09 21:13:45 -0600 |
| commit | a933b5850754931538f40af6e2767eb27fb6e904 (patch) | |
| tree | df0178e39d530a7313a0555af7f15a008f20344e /Library | |
| parent | b6cbd08e931d68e6ed45367b45daa6f97d816627 (diff) | |
| download | brew-a933b5850754931538f40af6e2767eb27fb6e904.tar.bz2 | |
versions: restore original constant
Before:
f1 = Formula.factory('tree')
f1.versions
f2 = Formula.factory('tree')
f1.class == f2.class # => false
After:
f1 = Formula.factory('tree')
f1.versions
f2 = Formula.factory('tree')
f1.class == f2.class # => true
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/versions.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/formulary.rb | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index 7e556ec55..feb908340 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -108,7 +108,7 @@ class Formula # Unload the class so Formula#version returns the correct value begin - Formulary.unload_formula name + old_const = Formulary.unload_formula name nostdout { yield Formula.factory(path.to_s) } rescue *IGNORED_EXCEPTIONS => e # We rescue these so that we can skip bad versions and @@ -116,6 +116,8 @@ class Formula ohai "#{e} in #{name} at revision #{sha}", e.backtrace if ARGV.debug? rescue FormulaUnavailableError # Suppress this error + ensure + Formulary.restore_formula name, old_const end end end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index a5bb5e306..c4e1be1c7 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -13,6 +13,13 @@ class Formulary Object.const_get(Formula.class_s(formula_name)) end + def self.restore_formula formula_name, value + old_verbose, $VERBOSE = $VERBOSE, nil + Object.const_set(Formula.class_s(formula_name), value) + ensure + $VERBOSE = old_verbose + end + # A FormulaLoader returns instances of formulae. # Subclasses implement loaders for particular sources of formulae. class FormulaLoader |
