info: show correct file origin for formula from path or url

Closes Homebrew/homebrew#36733.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Xu Cheng 2015-11-02 19:11:17 +08:00 committed by Mike McQuaid
parent e34d9a7b37
commit 56f7208f8e

View File

@ -65,13 +65,14 @@ module Homebrew
if f.tap? if f.tap?
user, repo = f.tap.split("/", 2) user, repo = f.tap.split("/", 2)
path = f.path.relative_path_from(HOMEBREW_LIBRARY.join("Taps", f.tap)) path = f.path.relative_path_from(HOMEBREW_LIBRARY.join("Taps", f.tap))
else "https://github.com/#{user}/#{repo}/blob/master/#{path}"
elsif f.core_formula?
user = f.path.parent.cd { github_fork } user = f.path.parent.cd { github_fork }
repo = "homebrew"
path = f.path.relative_path_from(HOMEBREW_REPOSITORY) path = f.path.relative_path_from(HOMEBREW_REPOSITORY)
"https://github.com/#{user}/homebrew/blob/master/#{path}"
else
f.path
end end
"https://github.com/#{user}/#{repo}/blob/master/#{path}"
end end
def info_formula f def info_formula f