-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make brew tap-info
show commit hash for taps that don't use the JSON API (_i.e._, are cloned locally)
#18381
Comments
Thanks @benknoble, this loosely makes sense to me. Which would have been more useful to solve the problem you faced: the actual SHA of the commit, the date of the commit or both/neither? |
I think the SHA; I can get the date from that easily enough with access to the corresponding repo. (A way to include the result of |
I asked because in
so the code is already there to do similar stuff so it may make sense for both consistency and given the existing helpers to do that |
Will review PR for this. This code may be useful: brew/Library/Homebrew/system_config.rb Lines 110 to 133 in bd3c7f8
Would suggest we do something consistently here both for JSON and Git taps. |
Yep, if the date's already available easily I don't see any problems including it.
Great! I'll find some time, hopefully soon, to work on this. |
So far, this seems to do something like what I want for both diff --git i/Library/Homebrew/cmd/tap-info.rb w/Library/Homebrew/cmd/tap-info.rb
index 2d00a70cb..bca548660 100644
--- i/Library/Homebrew/cmd/tap-info.rb
+++ w/Library/Homebrew/cmd/tap-info.rb
@@ -76,6 +76,10 @@ def print_tap_info(taps)
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
diff --git i/Library/Homebrew/tap.rb w/Library/Homebrew/tap.rb
index dd78d0a97..4bf635058 100644
--- i/Library/Homebrew/tap.rb
+++ w/Library/Homebrew/tap.rb
@@ -881,6 +881,9 @@ def to_hash
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 Thoughts? It would be nice to avoid the duplicated code spread across 3 files, of course, but I'm not Ruby expert :) I did attempt a version of |
@benknoble That makes sense to me. I think the duplication here is fine. Can you open a PR? Thanks! |
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 Homebrew#18381
Verification
brew install wget
. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.Provide a detailed description of the proposed feature
Currently,
brew tap-info <tap>
provides a small amount of information about a tap; using--verbose
does not provide more information, but using--json
does.In none of the above modes are tap versions shown, which can be helpful when troubleshooting an issue with a custom tap and formula that revolves around the version of both tap and formula.
The proposed feature is to add a
version
field to the JSON and text-based outputs oftap-info
that indicates the Git commit hash of the currently checked-out tap, just as ifgit -C $(brew --repository)/Library/Taps/<tap> rev-parse HEAD
were run.What is the motivation for the feature?
As stated in the proposal, this provides useful debugging information:
How will the feature be relevant to at least 90% of Homebrew users?
This feature can lead to quicker resolution of issues with formula from 3rd-party taps. For taps that use the JSON API, like homebrew/core, this will be less relevant (but
brew tap-info homebrew/core
reports "Not Installed" now, so I don't think that's a concern).What alternatives to the feature have been considered?
I mentioned
git -C $(brew --repository)/Library/Taps/<tap> rev-parse HEAD
earlier: this is one way to request the relevant information. It adds an extra step for everyone involved in troubleshooting issues, however. Placing the information inbrew tap-info
makes the tap more self-describing and seems like a natural fit.The text was updated successfully, but these errors were encountered: