feat(tap-info): display Git information about non-Core/non-API taps

Copy and tweak code from Library/Homebrew/system_config.rb:110 to commit
and date information. This information can be useful when debugging
formulae in custom taps to ensure the tap has been correctly updated
recently or to suss out important differences from one version of a tap
to another.

This removes the need to ask users to run something like

    git -C $(brew --repository)/Library/Taps/<tap> show -s --decorate

Close https://github.com/Homebrew/brew/issues/18381
This commit is contained in:
D. Ben Knoble 2024-09-30 11:27:35 -04:00
parent 0ac568bb97
commit 3429e74d7e
2 changed files with 7 additions and 0 deletions

View File

@ -76,6 +76,10 @@ module Homebrew
info += "\nPrivate" if tap.private?
info += "\n#{tap.path} (#{tap.path.abv})"
info += "\nFrom: #{tap.remote.presence || "N/A"}"
info += "\norigin: #{tap.remote}" if tap.remote != tap.default_remote
info += "\nHEAD: #{tap.git_head || "(none)"}"
info += "\nlast commit: #{tap.git_last_commit || "never"}"
info += "\nbranch: #{tap.git_branch || "(none)"}" if tap.git_branch != "master"
else
info += "Not installed"
end

View File

@ -881,6 +881,9 @@ class Tap
hash["remote"] = remote
hash["custom_remote"] = custom_remote?
hash["private"] = private?
hash["HEAD"] = git_head || "(none)"
hash["last_commit"] = git_last_commit || "never"
hash["branch"] = git_branch || "(none)"
end
hash