diff options
Diffstat (limited to 'Library/Homebrew/utils')
| -rw-r--r-- | Library/Homebrew/utils/analytics.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/utils/analytics.sh | 53 | ||||
| -rw-r--r-- | Library/Homebrew/utils/fork.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/utils/tty.rb | 5 |
4 files changed, 14 insertions, 71 deletions
diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 7dd54d3f1..23000f8dd 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -61,22 +61,15 @@ module Utils ev: value) end - def report_exception(exception, options = {}) - if exception.is_a?(BuildError) && - exception.formula.tap && - exception.formula.tap.installed? && - !exception.formula.tap.private? - report_event("BuildError", exception.formula.full_name) + def report_build_error(exception) + return unless exception.formula.tap + return unless exception.formula.tap.installed? + return if exception.formula.tap.private? + action = exception.formula.full_name + if (options = exception.options) + action = "#{action} #{options}".strip end - - fatal = options.fetch(:fatal, true) ? "1" : "0" - report(:exception, - exd: exception.class.name, - exf: fatal) - end - - def report_screenview(screen_name) - report(:screenview, cd: screen_name) + report_event("BuildError", action) end end end diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh index 8d5cf2ff7..00527fd9f 100644 --- a/Library/Homebrew/utils/analytics.sh +++ b/Library/Homebrew/utils/analytics.sh @@ -66,56 +66,3 @@ setup-analytics() { export HOMEBREW_ANALYTICS_ID export HOMEBREW_ANALYTICS_USER_UUID } - -report-analytics-screenview-command() { - [[ -n "$HOMEBREW_NO_ANALYTICS" || -n "$HOMEBREW_NO_ANALYTICS_THIS_RUN" ]] && return - - # Don't report commands that are invoked as part of other commands. - [[ "$HOMEBREW_COMMAND_DEPTH" != 1 ]] && return - - # Don't report non-official commands. - if ! [[ "$HOMEBREW_COMMAND" = "bundle" || - "$HOMEBREW_COMMAND" = "services" || - -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.rb" || - -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" || - -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.rb" || - -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]] - then - return - fi - - # Don't report commands used mostly by our scripts and not users. - case "$HOMEBREW_COMMAND" in - --prefix|analytics|command|commands) - return - ;; - esac - - local args=( - --max-time 3 - --user-agent "$HOMEBREW_USER_AGENT_CURL" - --data v=1 - --data aip=1 - --data t=screenview - --data tid="$HOMEBREW_ANALYTICS_ID" - --data cid="$HOMEBREW_ANALYTICS_USER_UUID" - --data an="$HOMEBREW_PRODUCT" - --data av="$HOMEBREW_VERSION" - --data cd="$HOMEBREW_COMMAND" - ) - - # Send analytics. Don't send or store any personally identifiable information. - # http://docs.brew.sh/Analytics.html - # https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#screenView - # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters - if [[ -z "$HOMEBREW_ANALYTICS_DEBUG" ]] - then - "$HOMEBREW_CURL" https://www.google-analytics.com/collect \ - "${args[@]}" \ - --silent --output /dev/null &>/dev/null & disown - else - local url="https://www.google-analytics.com/debug/collect" - echo "$HOMEBREW_CURL $url ${args[*]}" - "$HOMEBREW_CURL" "$url" "${args[@]}" - fi -} diff --git a/Library/Homebrew/utils/fork.rb b/Library/Homebrew/utils/fork.rb index 35a55980e..92f5bf899 100644 --- a/Library/Homebrew/utils/fork.rb +++ b/Library/Homebrew/utils/fork.rb @@ -37,8 +37,8 @@ module Utils read.close Process.wait(pid) unless socket.nil? raise Marshal.load(data) unless data.nil? || data.empty? - raise Interrupt if $?.exitstatus == 130 - raise "Suspicious failure" unless $?.success? + raise Interrupt if $CHILD_STATUS.exitstatus == 130 + raise "Suspicious failure" unless $CHILD_STATUS.success? end end end diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb index 642a33b91..e872e6460 100644 --- a/Library/Homebrew/utils/tty.rb +++ b/Library/Homebrew/utils/tty.rb @@ -6,7 +6,10 @@ module Tty end def width - (`/bin/stty size`.split[1] || 80).to_i + width = `/bin/stty size 2>/dev/null`.split[1] + width ||= `/usr/bin/tput cols 2>/dev/null`.split[0] + width ||= 80 + width.to_i end def truncate(string) |
