aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2016-04-04 11:46:33 +0100
committerMike McQuaid2016-04-04 12:18:21 +0100
commit77611bafb1dfc68e9cd59fb21163aefa53fccf2c (patch)
treef7be38a5ad3143451608a27bb52cc26d177ff24e /Library/Homebrew
parentac8088304603a95e2ae4d187016a50c36c622605 (diff)
downloadbrew-77611bafb1dfc68e9cd59fb21163aefa53fccf2c.tar.bz2
Make Homebrew user agent consistent, use a slash.
Generally it seems user agents are all `software/version` but ours is not. Also, set the user agent in a way that it's shared between Bash and Ruby code. Closes https://github.com/Homebrew/legacy-homebrew/pull/50480.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/update.sh2
-rw-r--r--Library/Homebrew/global.rb3
-rw-r--r--Library/Homebrew/os.rb4
-rw-r--r--Library/Homebrew/os/mac.rb2
-rw-r--r--Library/Homebrew/utils.rb11
5 files changed, 9 insertions, 13 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index 49dcb5038..d6ce41b00 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -306,7 +306,7 @@ EOS
# (so the API does not return 304: unmodified).
UPSTREAM_SHA_HTTP_CODE="$(curl --silent '--max-time' 3 \
--output /dev/null --write-out "%{http_code}" \
- --user-agent "Homebrew $HOMEBREW_VERSION" \
+ --user-agent "$HOMEBREW_USER_AGENT_CURL" \
--header "Accept: application/vnd.github.chitauri-preview+sha" \
--header "If-None-Match: \"$UPSTREAM_BRANCH_LOCAL_SHA\"" \
"https://api.github.com/repos/$UPSTREAM_REPOSITORY/commits/$UPSTREAM_BRANCH")"
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index cd0baf742..e6b7f7e5d 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -26,7 +26,8 @@ else
end
RUBY_BIN = RUBY_PATH.dirname
-HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"
+HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"]
+HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
HOMEBREW_CURL_ARGS = "-f#LA"
diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb
index 1b8ed7b8e..b0d685fa4 100644
--- a/Library/Homebrew/os.rb
+++ b/Library/Homebrew/os.rb
@@ -7,6 +7,8 @@ module OS
/linux/i === RUBY_PLATFORM
end
+ ::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
+
if OS.mac?
require "os/mac"
ISSUES_URL = "https://git.io/brew-troubleshooting"
@@ -14,13 +16,11 @@ module OS
# compatibility
::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
::MACOS_VERSION = OS::Mac.version.to_s
- ::OS_VERSION = "OS X #{MACOS_FULL_VERSION}"
elsif OS.linux?
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
PATH_OPEN = "xdg-open"
# compatibility
::MACOS_FULL_VERSION = ::MACOS_VERSION = "0"
- ::OS_VERSION = RUBY_PLATFORM
else
raise "Unknown operating system"
end
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb
index af27911eb..fcaaf2723 100644
--- a/Library/Homebrew/os/mac.rb
+++ b/Library/Homebrew/os/mac.rb
@@ -21,7 +21,7 @@ module OS
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
def full_version
- @full_version ||= Version.new(`/usr/bin/sw_vers -productVersion`.chomp)
+ @full_version ||= Version.new(ENV["HOMEBREW_OSX_VERSION"].chomp)
end
def prerelease?
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 509a5ff20..f5fb738e7 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -309,18 +309,13 @@ def quiet_system(cmd, *args)
end
def curl(*args)
- brewed_curl = HOMEBREW_PREFIX/"opt/curl/bin/curl"
- curl = if MacOS.version <= "10.8" && brewed_curl.exist?
- brewed_curl
- else
- Pathname.new "/usr/bin/curl"
- end
+ curl = Pathname.new ENV["HOMEBREW_CURL"]
raise "#{curl} is not executable" unless curl.exist? && curl.executable?
flags = HOMEBREW_CURL_ARGS
flags = flags.delete("#") if ARGV.verbose?
- args = [flags, HOMEBREW_USER_AGENT, *args]
+ args = [flags, HOMEBREW_USER_AGENT_CURL, *args]
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
args << "--silent" if !$stdout.tty? || ENV["TRAVIS"]
@@ -594,7 +589,7 @@ module GitHub
def api_headers
{
- "User-Agent" => HOMEBREW_USER_AGENT,
+ "User-Agent" => HOMEBREW_USER_AGENT_RUBY,
"Accept" => "application/vnd.github.v3+json"
}
end