diff options
| author | Jiang Xin | 2013-04-09 11:01:58 +0800 |
|---|---|---|
| committer | Jack Nagel | 2013-04-11 23:45:15 -0500 |
| commit | f30200890e31dd846cdc3015ac8e531e642b04eb (patch) | |
| tree | a308ba03a97de77c5e38003a65a2da5b64d7aebf /Library/Homebrew | |
| parent | 79c745cc76866dc6c33e1108650f71a9760a7e3d (diff) | |
| download | brew-f30200890e31dd846cdc3015ac8e531e642b04eb.tar.bz2 | |
versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.
Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.
Closes Homebrew/homebrew#12356.
Closes Homebrew/homebrew#19069.
Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/cmd/versions.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index f6aaea77c..205f4467e 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -37,23 +37,39 @@ class Formula end def pretty_relative_path - if Pathname.pwd == HOMEBREW_REPOSITORY - "Library/Formula/#{name}.rb" + if Pathname.pwd == repository + entry_name else - "#{HOMEBREW_REPOSITORY}/Library/Formula/#{name}.rb" + repository/"#{entry_name}" end end private + def repository + @repository ||= begin + if path.realpath.to_s =~ %r{#{HOMEBREW_REPOSITORY}/Library/Taps/(\w+)-(\w+)} + HOMEBREW_REPOSITORY/"Library/Taps/#$1-#$2" + else + HOMEBREW_REPOSITORY + end + end + end + + def entry_name + @entry_name ||= begin + repository == HOMEBREW_REPOSITORY ? "Library/Formula/#{name}.rb" : "#{name}.rb" + end + end + def rev_list - HOMEBREW_REPOSITORY.cd do - `git rev-list --abbrev-commit HEAD -- Library/Formula/#{name}.rb`.split + repository.cd do + `git rev-list --abbrev-commit HEAD -- #{entry_name}`.split end end def text_from_sha sha - HOMEBREW_REPOSITORY.cd do - `git cat-file blob #{sha}:Library/Formula/#{name}.rb` + repository.cd do + `git cat-file blob #{sha}:#{entry_name}` end end |
