dev-cmd/unbottled: Fail nicely if analytics data can't be retrieved
- When testing `brew unbottled <formula>` this crashed because I, as a maintainer, have `HOMEBREW_NO_ANALYTICS` set on all my machines to avoid polluting the analytics with test installs. ``` ❯ brew unbottled ==> Getting formulae... ==> Getting analytics data... Error: undefined method `[]' for nil:NilClass /usr/local/Homebrew/Library/Homebrew/dev-cmd/unbottled.rb:89:in `formulae_all_sort_installs_from_args' /usr/local/Homebrew/Library/Homebrew/dev-cmd/unbottled.rb:49:in `unbottled' /usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>' ```
This commit is contained in:
parent
5786a8937d
commit
ca999a81f7
@ -86,6 +86,13 @@ module Homebrew
|
||||
|
||||
ohai "Getting analytics data..."
|
||||
analytics = Utils::Analytics.formulae_brew_sh_json("analytics/install/90d.json")
|
||||
|
||||
if analytics.blank?
|
||||
raise UsageError,
|
||||
"default sort by analytics data requires " \
|
||||
"`HOMEBREW_NO_GITHUB_API` and `HOMEBREW_NO_ANALYTICS` to be unset"
|
||||
end
|
||||
|
||||
formulae = analytics["items"].map do |i|
|
||||
f = i["formula"].split.first
|
||||
next if f.include?("/")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user