Skip to content

Commit

Permalink
versions: use the actual class name when unloading
Browse files Browse the repository at this point in the history
And document a bit more why this hack is present.

Signed-off-by: Jack Nagel <[email protected]>
  • Loading branch information
jacknagel committed Jan 12, 2012
1 parent 29741d2 commit ed2202d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Library/Homebrew/cmd/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ def version_for_sha sha
mktemp do
path = Pathname.new(Pathname.pwd+"#{name}.rb")
path.write text_from_sha(sha)
# FIXME: shouldn't have to do this?
Object.send(:remove_const, "#{name.capitalize}")

# Unload the class so Formula#version returns the correct value.
# Note that this means that the command will error out after it
# encounters a formula that won't import. This doesn't matter
# for most formulae, but e.g. Bash at revision aae084c9db has a
# syntax error and so `versions` isn't able to walk very far back
# through the history.
# FIXME shouldn't have to do this?
Object.send(:remove_const, "#{Formula.class_s(name)}")
Formula.factory(path).version
end rescue nil
end
Expand Down

0 comments on commit ed2202d

Please sign in to comment.