未验证 提交 ca999a81 编辑于 作者: Issy Long's avatar Issy Long
浏览文件

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>'
```
上级 5786a893
......@@ -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?("/")
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册