From 93cac4cceed5dd76f844bcda30194e8858267fa7 Mon Sep 17 00:00:00 2001 From: Chongyu Zhu Date: Fri, 14 Sep 2018 18:50:03 +0800 Subject: [PATCH 1/2] utils/analytics: make `curl` respect `HOMEBREW_CURLRC` --- Library/Homebrew/utils/analytics.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 84a5c93a38..f52d9ab722 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -24,7 +24,12 @@ module Utils def report(type, metadata = {}) return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] - args = %W[ + args = [] + + # do not load .curlrc unless requested (must be the first argument) + args << "-q" unless ENV["HOMEBREW_CURLRC"] + + args += %W[ --max-time 3 --user-agent #{HOMEBREW_USER_AGENT_CURL} --data v=1 @@ -49,14 +54,14 @@ module Utils # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters if ENV["HOMEBREW_ANALYTICS_DEBUG"] url = "https://www.google-analytics.com/debug/collect" - puts "#{ENV["HOMEBREW_CURL"]} #{url} #{args.join(" ")}" - puts Utils.popen_read ENV["HOMEBREW_CURL"], url, *args + puts "#{ENV["HOMEBREW_CURL"]} #{args.join(" ")} #{url}" + puts Utils.popen_read ENV["HOMEBREW_CURL"], *args, url else pid = fork do exec ENV["HOMEBREW_CURL"], - "https://www.google-analytics.com/collect", + *args, "--silent", "--output", "/dev/null", - *args + "https://www.google-analytics.com/collect" end Process.detach pid end From cc0f17eb7bbed39dc2c0367d6b7218485c38d317 Mon Sep 17 00:00:00 2001 From: Chongyu Zhu Date: Fri, 14 Sep 2018 18:50:21 +0800 Subject: [PATCH 2/2] cmd/update: make `curl` respect `HOMEBREW_CURLRC` --- Library/Homebrew/cmd/update.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 30ba7cec96..a23b41e605 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -406,6 +406,13 @@ EOS QUIET_ARGS=() fi + if [[ -z "$HOMEBREW_CURLRC" ]] + then + CURL_DISABLE_CURLRC_ARGS=(-q) + else + CURL_DISABLE_CURLRC_ARGS=() + fi + # only allow one instance of brew update lock update @@ -481,7 +488,9 @@ EOS GITHUB_API_ENDPOINT="commits/$UPSTREAM_BRANCH_DIR" fi - UPSTREAM_SHA_HTTP_CODE="$("$HOMEBREW_CURL" --silent --max-time 3 \ + UPSTREAM_SHA_HTTP_CODE="$("$HOMEBREW_CURL" \ + "${CURL_DISABLE_CURLRC_ARGS[@]}" \ + --silent --max-time 3 \ --location --output /dev/null --write-out "%{http_code}" \ --dump-header "$DIR/.git/GITHUB_HEADERS" \ --user-agent "$HOMEBREW_USER_AGENT_CURL" \