Use Homebrew::EnvConfig.

This commit is contained in:
Mike McQuaid 2020-04-05 15:44:50 +01:00
parent fb0052068f
commit 3381cbf5c7
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
52 changed files with 184 additions and 265 deletions

View File

@ -28,10 +28,10 @@ class BottlePublisher
end
def publish_changed_formula_bottles
raise "Need to load formulae to publish them!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
raise "Need to load formulae to publish them!" if Homebrew::EnvConfig.disable_load_formula?
published = []
bintray_creds = { user: ENV["HOMEBREW_BINTRAY_USER"], key: ENV["HOMEBREW_BINTRAY_KEY"] }
bintray_creds = { user: Homebrew::EnvConfig.bintray_user, key: Homebrew::EnvConfig.bintray_key }
if bintray_creds[:user] && bintray_creds[:key]
@changed_formulae_names.each do |name|
f = Formula[name]
@ -82,7 +82,7 @@ class BottlePublisher
def verify_bintray_published(formulae_names)
return if formulae_names.empty?
raise "Need to load formulae to verify their publication!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
raise "Need to load formulae to verify their publication!" if Homebrew::EnvConfig.disable_load_formula?
ohai "Verifying bottles published on Bintray"
formulae = formulae_names.map { |n| Formula[n] }

View File

@ -76,7 +76,7 @@ begin
internal_cmd = Commands.valid_internal_cmd?(cmd)
internal_cmd ||= begin
internal_dev_cmd = Commands.valid_internal_dev_cmd?(cmd)
if internal_dev_cmd && !ARGV.homebrew_developer?
if internal_dev_cmd && !Homebrew::EnvConfig.developer?
if (HOMEBREW_REPOSITORY/".git/config").exist?
system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
"--replace-all", "homebrew.devcmdrun", "true"
@ -172,7 +172,7 @@ rescue MethodDeprecatedError => e
rescue Exception => e # rubocop:disable Lint/RescueException
onoe e
if internal_cmd && defined?(OS::ISSUES_URL) &&
!ENV["HOMEBREW_NO_AUTO_UPDATE"]
!Homebrew::EnvConfig.no_auto_update?
$stderr.puts "#{Tty.bold}Please report this issue:#{Tty.reset}"
$stderr.puts " #{Formatter.url(OS::ISSUES_URL)}"
end

View File

@ -136,9 +136,9 @@ then
HOMEBREW_FORCE_BREWED_GIT="1"
fi
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew}"
HOMEBREW_SYSTEM_TEMP="/private/tmp"
HOMEBREW_DEFAULT_CACHE="${HOME}/Library/Caches/Homebrew"
HOMEBREW_DEFAULT_LOGS="${HOME}/Library/Logs/Homebrew"
HOMEBREW_DEFAULT_TEMP="/private/tmp"
# Set a variable when the macOS system Ruby is new enough to avoid spawning
# a Ruby process unnecessarily.
@ -180,9 +180,9 @@ else
fi
CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${CACHE_HOME}/Homebrew/Logs}"
HOMEBREW_SYSTEM_TEMP="/tmp"
HOMEBREW_DEFAULT_CACHE="${CACHE_HOME}/Homebrew"
HOMEBREW_DEFAULT_LOGS="${CACHE_HOME}/Homebrew/Logs"
HOMEBREW_DEFAULT_TEMP="/tmp"
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
fi
@ -194,7 +194,9 @@ else
HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://linuxbrew.bintray.com"
fi
HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_SYSTEM_TEMP}}"
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOMEBREW_DEFAULT_CACHE}}"
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOMEBREW_DEFAULT_LOGS}}"
HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}"
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
@ -230,13 +232,15 @@ export HOMEBREW_BREW_FILE
export HOMEBREW_PREFIX
export HOMEBREW_REPOSITORY
export HOMEBREW_LIBRARY
export HOMEBREW_SYSTEM_TEMP
export HOMEBREW_TEMP
# Declared in brew.sh
export HOMEBREW_VERSION
export HOMEBREW_DEFAULT_CACHE
export HOMEBREW_CACHE
export HOMEBREW_DEFAULT_LOGS
export HOMEBREW_LOGS
export HOMEBREW_DEFAULT_TEMP
export HOMEBREW_TEMP
export HOMEBREW_CELLAR
export HOMEBREW_SYSTEM
export HOMEBREW_CURL
@ -374,23 +378,24 @@ then
export HOMEBREW_BOTTLE_DOMAIN="$HOMEBREW_BOTTLE_DEFAULT_DOMAIN"
fi
HOMEBREW_DEFAULT_BREW_GIT_REMOTE="https://github.com/Homebrew/brew"
export HOMEBREW_BREW_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/brew"
if [[ -z "$HOMEBREW_BREW_GIT_REMOTE" ]]
then
HOMEBREW_BREW_GIT_REMOTE="$HOMEBREW_DEFAULT_BREW_GIT_REMOTE"
HOMEBREW_BREW_GIT_REMOTE="$HOMEBREW_BREW_DEFAULT_GIT_REMOTE"
fi
export HOMEBREW_BREW_GIT_REMOTE
if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]]
then
HOMEBREW_DEFAULT_CORE_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
else
HOMEBREW_DEFAULT_CORE_GIT_REMOTE="https://github.com/Homebrew/linuxbrew-core"
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/linuxbrew-core"
fi
export HOMEBREW_CORE_DEFAULT_GIT_REMOTE
if [[ -z "$HOMEBREW_CORE_GIT_REMOTE" ]]
then
HOMEBREW_CORE_GIT_REMOTE="$HOMEBREW_DEFAULT_CORE_GIT_REMOTE"
HOMEBREW_CORE_GIT_REMOTE="$HOMEBREW_CORE_DEFAULT_GIT_REMOTE"
fi
export HOMEBREW_CORE_GIT_REMOTE

View File

@ -140,7 +140,7 @@ module Cask
def summary
s = +""
s << "#{Emoji.install_badge} " if Emoji.enabled?
s << "#{Homebrew::EnvConfig.install_badge} " unless Homebrew::EnvConfig.no_emoji?
s << "#{@cask} was successfully #{upgrade? ? "upgraded" : "installed"}!"
s.freeze
end

View File

@ -138,7 +138,7 @@ module Homebrew
end
def self.install_formula_clean!(f)
return if ENV["HOMEBREW_NO_INSTALL_CLEANUP"]
return if Homebrew::EnvConfig.no_install_cleanup?
cleanup = Cleanup.new
if cleanup.periodic_clean_due?
@ -149,7 +149,7 @@ module Homebrew
end
def periodic_clean_due?
return false if ENV["HOMEBREW_NO_INSTALL_CLEANUP"]
return false if Homebrew::EnvConfig.no_install_cleanup?
return true unless PERIODIC_CLEAN_FILE.exist?
PERIODIC_CLEAN_FILE.mtime < CLEANUP_DEFAULT_DAYS.days.ago
@ -337,7 +337,7 @@ module Homebrew
.chomp
use_system_ruby = (
Gem::Version.new(system_ruby_version) >= Gem::Version.new(RUBY_VERSION)
) && ENV["HOMEBREW_FORCE_VENDOR_RUBY"].nil?
) && !Homebrew::EnvConfig.force_vendor_ruby?
vendor_path = HOMEBREW_LIBRARY/"Homebrew/vendor"
portable_ruby_version_file = vendor_path/"portable-ruby-version"
portable_ruby_version = if portable_ruby_version_file.exist?

View File

@ -83,7 +83,11 @@ module Homebrew
alias switch_option switch
def env?(env)
env.present? && ENV["HOMEBREW_#{env.to_s.upcase}"].present?
return false if env.blank?
Homebrew::EnvConfig.send("#{env}?")
rescue NoMethodError
false
end
def usage_banner(text)

View File

@ -20,10 +20,10 @@ module Homebrew
cat_args.parse
cd HOMEBREW_REPOSITORY
pager = if ENV["HOMEBREW_BAT"].nil?
"cat"
else
pager = if Homebrew::EnvConfig.bat?
"#{HOMEBREW_PREFIX}/bin/bat"
else
"cat"
end
safe_system pager, args.formulae.first.path, *args.passthrough
end

View File

@ -68,7 +68,7 @@ module Homebrew
rescue Interrupt
raise
rescue => e
raise if ARGV.homebrew_developer?
raise if Homebrew::EnvConfig.developer?
fetched_bottle = false
onoe e.message

View File

@ -98,7 +98,7 @@ module Homebrew
puts "#{n} symlinks created"
end
puts_keg_only_path_message(keg) if keg_only && !ARGV.homebrew_developer?
puts_keg_only_path_message(keg) if keg_only && !Homebrew::EnvConfig.developer?
end
end
end

View File

@ -110,7 +110,7 @@ module Homebrew
def check_for_dependents(kegs)
return false unless result = Keg.find_some_installed_dependents(kegs)
if ARGV.homebrew_developer?
if Homebrew::EnvConfig.developer?
DeveloperDependentsMessage.new(*result).output
else
NondeveloperDependentsMessage.new(*result).output

View File

@ -97,7 +97,7 @@ module Homebrew
begin
reporter = Reporter.new(tap)
rescue Reporter::ReporterRevisionUnsetError => e
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if ARGV.homebrew_developer?
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if Homebrew::EnvConfig.developer?
next
end
if reporter.updated?
@ -225,7 +225,7 @@ class Reporter
# Don't care if the formula isn't available right now.
nil
rescue Exception => e # rubocop:disable Lint/RescueException
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if ARGV.homebrew_developer?
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if Homebrew::EnvConfig.developer?
end
@report[:M] << tap.formula_file_to_name(src)
when /^R\d{0,3}/
@ -316,7 +316,7 @@ class Reporter
system HOMEBREW_BREW_FILE, "link", new_full_name, "--overwrite"
end
rescue Exception => e # rubocop:disable Lint/RescueException
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if ARGV.homebrew_developer?
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if Homebrew::EnvConfig.developer?
end
next
end
@ -380,7 +380,7 @@ class Reporter
begin
f = Formulary.factory(new_full_name)
rescue Exception => e # rubocop:disable Lint/RescueException
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if ARGV.homebrew_developer?
onoe "#{e.message}\n#{e.backtrace.join "\n"}" if Homebrew::EnvConfig.developer?
next
end

View File

@ -30,7 +30,7 @@ git_init_if_necessary() {
trap '{ rm -rf .git; exit 1; }' EXIT
git init
git config --bool core.autocrlf false
if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
if [[ "$HOMEBREW_BREW_DEFAULT_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
then
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote URL."
fi
@ -52,7 +52,7 @@ git_init_if_necessary() {
trap '{ rm -rf .git; exit 1; }' EXIT
git init
git config --bool core.autocrlf false
if [[ "$HOMEBREW_DEFAULT_CORE_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]]
if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]]
then
echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/core Git remote URL."
fi
@ -414,7 +414,7 @@ EOS
git_init_if_necessary
if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
if [[ "$HOMEBREW_BREW_DEFAULT_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
then
safe_cd "$HOMEBREW_REPOSITORY"
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote."
@ -424,7 +424,7 @@ EOS
git fetch --force origin --shallow-since="$latest_tag"
fi
if [[ "$HOMEBREW_DEFAULT_CORE_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] &&
if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] &&
[[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]]
then
safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core"

View File

@ -114,7 +114,7 @@ module Homebrew
ENV["PATH"] = ENV["HOMEBREW_PATH"]
# Use the user's browser, too.
ENV["BROWSER"] = ENV["HOMEBREW_BROWSER"]
ENV["BROWSER"] = Homebrew::EnvConfig.browser
formula = args.formulae.first

View File

@ -108,7 +108,7 @@ module Homebrew
end
destination_tap = Tap.fetch(args.named.second)
unless ARGV.homebrew_developer?
unless Homebrew::EnvConfig.developer?
odie "Cannot extract formula to homebrew/core!" if destination_tap.core_tap?
odie "Cannot extract formula to the same tap!" if destination_tap == source_tap
end

View File

@ -22,8 +22,8 @@ module Homebrew
def mirror
mirror_args.parse
bintray_user = ENV["HOMEBREW_BINTRAY_USER"]
bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
bintray_user = Homebrew::EnvConfig.bintray_user
bintray_key = Homebrew::EnvConfig.bintray_key
raise "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!" if !bintray_user || !bintray_key
args.formulae.each do |f|

View File

@ -72,8 +72,7 @@ module Homebrew
pull_args.parse
# Passthrough Git environment variables for e.g. git am
ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"]
ENV["GIT_COMMITTER_EMAIL"] = ENV["HOMEBREW_GIT_EMAIL"] if ENV["HOMEBREW_GIT_EMAIL"]
Utils.set_git_name_email!(author: false, committer: true)
# Depending on user configuration, git may try to invoke gpg.
if Utils.popen_read("git config --get --bool commit.gpgsign").chomp == "true"
@ -168,7 +167,7 @@ module Homebrew
fetch_bottles = false
changed_formulae_names.each do |name|
next if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
next if Homebrew::EnvConfig.disable_load_formula?
begin
f = Formula[name]
@ -213,7 +212,7 @@ module Homebrew
end
is_bumpable = false if args.clean?
is_bumpable = false if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
is_bumpable = false if Homebrew::EnvConfig.disable_load_formula?
if is_bumpable
formula = Formula[changed_formulae_names.first]

View File

@ -538,11 +538,11 @@ module Homebrew
end
def check_brew_git_origin
examine_git_origin(HOMEBREW_REPOSITORY, HOMEBREW_BREW_GIT_REMOTE)
examine_git_origin(HOMEBREW_REPOSITORY, Homebrew::EnvConfig.brew_git_remote)
end
def check_coretap_git_origin
examine_git_origin(CoreTap.instance.path, HOMEBREW_CORE_GIT_REMOTE)
examine_git_origin(CoreTap.instance.path, Homebrew::EnvConfig.core_git_remote)
end
def check_casktap_git_origin

View File

@ -345,8 +345,8 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
@resolved_info_cache ||= {}
return @resolved_info_cache[url] if @resolved_info_cache.include?(url)
if ENV["HOMEBREW_ARTIFACT_DOMAIN"]
url = url.sub(%r{^((ht|f)tps?://)?}, ENV["HOMEBREW_ARTIFACT_DOMAIN"].chomp("/") + "/")
if (domain = Homebrew::EnvConfig.artifact_domain)
url = url.sub(%r{^((ht|f)tps?://)?}, domain.chomp("/") + "/")
end
out, _, status= curl_output("--location", "--silent", "--head", "--request", "GET", url.to_s)
@ -402,7 +402,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
def _fetch(url:, resolved_url:)
ohai "Downloading from #{resolved_url}" if url != resolved_url
if ENV["HOMEBREW_NO_INSECURE_REDIRECT"] &&
if Homebrew::EnvConfig.no_insecure_redirect? &&
url.start_with?("https://") && !resolved_url.start_with?("https://")
$stderr.puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
raise CurlDownloadStrategyError, url
@ -784,7 +784,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
git_dir = dot_git.read.chomp[/^gitdir: (.*)$/, 1]
if git_dir.nil?
onoe "Failed to parse '#{dot_git}'." if ARGV.homebrew_developer?
onoe "Failed to parse '#{dot_git}'." if Homebrew::EnvConfig.developer?
next
end
@ -809,7 +809,7 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
end
def github_last_commit
return if ENV["HOMEBREW_NO_GITHUB_API"]
return if Homebrew::EnvConfig.no_github_api?
output, _, status = curl_output(
"--silent", "--head", "--location",
@ -825,7 +825,7 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
end
def multiple_short_commits_exist?(commit)
return if ENV["HOMEBREW_NO_GITHUB_API"]
return if Homebrew::EnvConfig.no_github_api?
output, _, status = curl_output(
"--silent", "--head", "--location",

View File

@ -1,13 +0,0 @@
# frozen_string_literal: true
module Emoji
class << self
def install_badge
ENV["HOMEBREW_INSTALL_BADGE"] || "🍺"
end
def enabled?
!ENV["HOMEBREW_NO_EMOJI"]
end
end
end

View File

@ -31,18 +31,6 @@ module HomebrewArgvExtension
flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
end
def homebrew_developer?
!ENV["HOMEBREW_DEVELOPER"].nil?
end
def skip_or_later_bottles?
homebrew_developer? && !ENV["HOMEBREW_SKIP_OR_LATER_BOTTLES"].nil?
end
def no_sandbox?
include?("--no-sandbox") || !ENV["HOMEBREW_NO_SANDBOX"].nil?
end
def build_bottle?
include?("--build-bottle")
end

View File

@ -169,7 +169,7 @@ module Stdenv
# Sets architecture-specific flags for every environment variable
# given in the list `flags`.
# @private
def set_cpu_flags(flags, map = Hardware::CPU.optimization_flags) # rubocop:disable Naming/AccessorMethodName
def set_cpu_flags(flags, map = Hardware::CPU.optimization_flags)
cflags =~ /(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=/
xarch = Regexp.last_match(1).to_s
remove flags, /(-Xarch_#{Hardware::CPU.arch_32_bit} )?-march=\S*/
@ -188,12 +188,7 @@ module Stdenv
end
def make_jobs
# '-j' requires a positive integral argument
if (jobs = self["HOMEBREW_MAKE_JOBS"].to_i).positive?
jobs
else
Hardware::CPU.cores
end
Homebrew::EnvConfig.make_jobs
end
# This method does nothing in stdenv since there's no arg refurbishment

View File

@ -217,11 +217,7 @@ module Superenv
end
def determine_make_jobs
if (j = self["HOMEBREW_MAKE_JOBS"].to_i) < 1
Hardware::CPU.cores
else
j
end
Homebrew::EnvConfig.make_jobs
end
def determine_optflags

View File

@ -3,9 +3,8 @@
module Hardware
class CPU
class << self
native_arch = (ENV["HOMEBREW_ARCH"] || "native").freeze
OPTIMIZATION_FLAGS_LINUX = {
native: "-march=#{native_arch}",
native: "-march=#{Homebrew::EnvConfig.arch}",
nehalem: "-march=nehalem",
core2: "-march=core2",
core: "-march=prescott",

View File

@ -93,7 +93,7 @@ class Keg
@bottle_dependencies ||= begin
formulae = relocation_formulae
gcc = Formula["gcc"]
if !ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] &&
if !Homebrew::EnvConfig.force_homebrew_on_linux? &&
DevelopmentTools.non_apple_gcc_version("gcc") < gcc.version.to_i
formulae += gcc.recursive_dependencies.map(&:name)
formulae << gcc.name

View File

@ -4,6 +4,6 @@ class CoreTap < Tap
# @private
def initialize
super "Homebrew", "core"
@full_name = "Homebrew/linuxbrew-core" unless ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
@full_name = "Homebrew/linuxbrew-core" unless Homebrew::EnvConfig.force_homebrew_on_linux?
end
end

View File

@ -4,13 +4,13 @@ module Utils
module Analytics
class << self
def formula_path
return generic_formula_path if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
return generic_formula_path if Homebrew::EnvConfig.force_homebrew_on_linux?
"formula-linux"
end
def analytics_path
return generic_analytics_path if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
return generic_analytics_path if Homebrew::EnvConfig.force_homebrew_on_linux?
"analytics-linux"
end

View File

@ -45,7 +45,7 @@ module Homebrew
end
def check_for_unsupported_macos
return if ARGV.homebrew_developer?
return if Homebrew::EnvConfig.developer?
who = +"We"
if OS::Mac.prerelease?
@ -141,7 +141,7 @@ module Homebrew
def check_ruby_version
ruby_version = "2.6.3"
return if RUBY_VERSION == ruby_version
return if ARGV.homebrew_developer? && OS::Mac.prerelease?
return if Homebrew::EnvConfig.developer? && OS::Mac.prerelease?
<<~EOS
Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew

View File

@ -17,7 +17,8 @@ module Utils
def find_matching_tag(tag)
# Used primarily by developers testing beta macOS releases.
if OS::Mac.prerelease? && ARGV.skip_or_later_bottles?
if OS::Mac.prerelease? && Homebrew::EnvConfig.developer? &&
Homebrew::EnvConfig.skip_or_later_bottles?
generic_find_matching_tag(tag)
else
generic_find_matching_tag(tag) ||

View File

@ -1891,7 +1891,7 @@ class Formula
# system "make", "install"</pre>
def system(cmd, *args)
verbose = Homebrew.args.verbose?
verbose_using_dots = !ENV["HOMEBREW_VERBOSE_USING_DOTS"].nil?
verbose_using_dots = Homebrew::EnvConfig.verbose_using_dots?
# remove "boring" arguments so that the important ones are more likely to
# be shown considering that we trim long ohai lines to the terminal width
@ -1962,8 +1962,7 @@ class Formula
$stdout.flush
unless $CHILD_STATUS.success?
log_lines = ENV["HOMEBREW_FAIL_LOG_LINES"]
log_lines ||= "15"
log_lines = Homebrew::EnvConfig.fail_log_lines
log.flush
if !verbose || verbose_using_dots

View File

@ -11,7 +11,6 @@ require "formula_cellar_checks"
require "install_renamed"
require "debrew"
require "sandbox"
require "emoji"
require "development_tools"
require "cache_store"
require "linkage_checker"
@ -306,9 +305,9 @@ class FormulaInstaller
end
formula.rack.rmdir_if_possible
end
raise if ARGV.homebrew_developer? ||
e.is_a?(Interrupt) ||
ENV["HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK"]
raise if Homebrew::EnvConfig.developer? ||
Homebrew::EnvConfig.no_bottle_source_fallback? ||
e.is_a?(Interrupt)
@pour_failed = true
onoe e.message
@ -372,7 +371,7 @@ class FormulaInstaller
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
EOS
raise if ARGV.homebrew_developer?
raise if Homebrew::EnvConfig.developer?
$stderr.puts "Please report this issue to the #{formula.tap} tap (not Homebrew/brew or Homebrew/core)!"
false
@ -621,7 +620,7 @@ class FormulaInstaller
def caveats
return if only_deps?
audit_installed if ARGV.homebrew_developer?
audit_installed if Homebrew::EnvConfig.developer?
caveats = Caveats.new(formula)
@ -684,7 +683,7 @@ class FormulaInstaller
def summary
s = +""
s << "#{Emoji.install_badge} " if Emoji.enabled?
s << "#{Homebrew::EnvConfig.install_badge} " unless Homebrew::EnvConfig.no_emoji?
s << "#{formula.prefix.resolved_path}: #{formula.prefix.abv}"
s << ", built in #{pretty_duration build_time}" if build_time
s.freeze
@ -943,7 +942,7 @@ class FormulaInstaller
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The post-install step did not complete successfully"
puts "You can try again using `brew postinstall #{formula.full_name}`"
ohai e, e.backtrace if debug? || ARGV.homebrew_developer?
ohai e, e.backtrace if debug? || Homebrew::EnvConfig.developer?
Homebrew.failed = true
@show_summary_heading = true
end

View File

@ -26,7 +26,7 @@ module Formulary
end
def self.load_formula(name, path, contents, namespace)
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula?
mod = Module.new
const_set(namespace, mod)

View File

@ -25,6 +25,14 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular "it", "they"
end
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"]
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_BREW_DEFAULT_GIT_REMOTE"]
HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"]
HOMEBREW_DEFAULT_CACHE = ENV["HOMEBREW_DEFAULT_CACHE"]
HOMEBREW_DEFAULT_LOGS = ENV["HOMEBREW_DEFAULT_LOGS"]
HOMEBREW_DEFAULT_TEMP = ENV["HOMEBREW_DEFAULT_TEMP"]
require "env_config"
require "config"
require "os"
require "extend/ARGV"
@ -51,12 +59,6 @@ HOMEBREW_USER_AGENT_FAKE_SAFARI =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 " \
"(KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"]
HOMEBREW_BOTTLE_DOMAIN = ENV["HOMEBREW_BOTTLE_DOMAIN"]
HOMEBREW_BREW_GIT_REMOTE = ENV["HOMEBREW_BREW_GIT_REMOTE"]
HOMEBREW_CORE_GIT_REMOTE = ENV["HOMEBREW_CORE_GIT_REMOTE"]
HOMEBREW_DEFAULT_PREFIX = "/usr/local"
LINUXBREW_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew"
@ -134,4 +136,4 @@ require "official_taps"
require "tap"
require "tap_constants"
require "compat" if !ARGV.include?("--no-compat") && !ENV["HOMEBREW_NO_COMPAT"]
require "compat" unless Homebrew::EnvConfig.no_compat?

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "utils/popen"
module Hardware
class CPU
INTEL_32BIT_ARCHS = [:i386].freeze

View File

@ -83,7 +83,7 @@ module Homebrew
output ||= comment_help(path)
output ||= if output.blank?
opoo "No help text in: #{path}" if ARGV.homebrew_developer?
opoo "No help text in: #{path}" if Homebrew::EnvConfig.developer?
HOMEBREW_HELP
end

View File

@ -10,7 +10,7 @@ module Language
# e.g. `resource "github.com/foo/bar"`
def self.stage_deps(resources, target)
if resources.empty?
if ARGV.homebrew_developer?
if Homebrew::EnvConfig.developer?
odie "tried to stage empty Language::Go resources array"
else
opoo "tried to stage empty Language::Go resources array"

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Homebrew
DEFAULT_PREFIX ||= if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
DEFAULT_PREFIX ||= if Homebrew::EnvConfig.force_homebrew_on_linux?
HOMEBREW_DEFAULT_PREFIX
else
LINUXBREW_DEFAULT_PREFIX

View File

@ -50,7 +50,7 @@ module MachOShim
rescue
# ... but complain about other (parse) errors for further investigation.
onoe "Failed to read Mach-O binary: #{self}"
raise if ARGV.homebrew_developer?
raise if Homebrew::EnvConfig.developer?
[]
end

View File

@ -10,16 +10,16 @@ class Sandbox
OS.mac? && File.executable?(SANDBOX_EXEC)
end
def self.formula?(_formula)
def self.formula?(_)
return false unless available?
!ARGV.no_sandbox?
!Homebrew.args.no_sandbox?
end
def self.test?
return false unless available?
!ARGV.no_sandbox?
!Homebrew.args.no_sandbox?
end
def initialize
@ -127,7 +127,7 @@ class Sandbox
end
end
if @failed && ENV["HOMEBREW_VERBOSE"].present?
if @failed && Homebrew::EnvConfig.verbose?
ohai "Sandbox log"
puts logs
$stdout.flush # without it, brew test-bot would fail to catch the log

View File

@ -30,7 +30,7 @@ module Homebrew
results = { formulae: [], casks: [] }
return results if ENV["HOMEBREW_NO_GITHUB_API"]
return results if Homebrew::EnvConfig.no_github_api?
unless silent
# Use stderr to avoid breaking parsed output

View File

@ -346,7 +346,7 @@ class BottleSpecification
def root_url(var = nil, specs = {})
if var.nil?
@root_url ||= "#{HOMEBREW_BOTTLE_DOMAIN}/#{Utils::Bottles::Bintray.repository(tap)}"
@root_url ||= "#{Homebrew::EnvConfig.bottle_domain}/#{Utils::Bottles::Bintray.repository(tap)}"
else
@root_url = var
@root_url_specs.merge!(specs)

View File

@ -119,67 +119,37 @@ class SystemConfig
else
f.puts "Core tap: N/A"
end
defaults_hash = {
HOMEBREW_PREFIX: Homebrew::DEFAULT_PREFIX,
f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}"
{
HOMEBREW_REPOSITORY: Homebrew::DEFAULT_REPOSITORY,
HOMEBREW_CELLAR: Homebrew::DEFAULT_CELLAR,
HOMEBREW_CACHE: "#{ENV["HOME"]}/Library/Caches/Homebrew",
HOMEBREW_LOGS: "#{ENV["HOME"]}/Library/Logs/Homebrew",
HOMEBREW_TEMP: ENV["HOMEBREW_SYSTEM_TEMP"],
HOMEBREW_RUBY_WARNINGS: "-W0",
}.freeze
boring_keys = %w[
HOMEBREW_BROWSER
HOMEBREW_EDITOR
HOMEBREW_ANALYTICS_ID
HOMEBREW_ANALYTICS_USER_UUID
HOMEBREW_AUTO_UPDATE_CHECKED
HOMEBREW_BOTTLE_DEFAULT_DOMAIN
HOMEBREW_BOTTLE_DOMAIN
HOMEBREW_BREW_FILE
HOMEBREW_BREW_GIT_REMOTE
HOMEBREW_COMMAND_DEPTH
HOMEBREW_CORE_GIT_REMOTE
HOMEBREW_CURL
HOMEBREW_DISPLAY
HOMEBREW_GIT
HOMEBREW_GIT_CONFIG_FILE
HOMEBREW_LIBRARY
HOMEBREW_MACOS_VERSION
HOMEBREW_MACOS_VERSION_NUMERIC
HOMEBREW_MINIMUM_GIT_VERSION
HOMEBREW_RUBY_PATH
HOMEBREW_SYSTEM
HOMEBREW_SYSTEM_TEMP
HOMEBREW_OS_VERSION
HOMEBREW_PATH
HOMEBREW_PROCESSOR
HOMEBREW_PRODUCT
HOMEBREW_USER_AGENT
HOMEBREW_USER_AGENT_CURL
HOMEBREW_VERSION
].freeze
f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}"
[:HOMEBREW_CELLAR, :HOMEBREW_CACHE, :HOMEBREW_LOGS, :HOMEBREW_REPOSITORY,
:HOMEBREW_TEMP].each do |key|
}.freeze.each do |key, default|
value = Object.const_get(key)
f.puts "#{key}: #{value}" if defaults_hash[key] != value.to_s
f.puts "#{key}: #{value}" if value.to_s != default.to_s
end
if defaults_hash[:HOMEBREW_RUBY_WARNINGS] != ENV["HOMEBREW_RUBY_WARNINGS"].to_s
f.puts "HOMEBREW_RUBY_WARNINGS: #{ENV["HOMEBREW_RUBY_WARNINGS"]}"
end
unless ENV["HOMEBREW_ENV"]
ENV.sort.each do |key, value|
next unless key.start_with?("HOMEBREW_")
next if key.start_with?("HOMEBREW_BUNDLE_")
next if boring_keys.include?(key)
next if defaults_hash[key.to_sym]
value = "set" if ENV.sensitive?(key)
f.puts "#{key}: #{value}"
Homebrew::EnvConfig::ENVS.each do |env, hash|
method_name = Homebrew::EnvConfig.env_method_name(env, hash)
if hash[:boolean]
f.puts "#{env}: set" if Homebrew::EnvConfig.send(method_name)
next
end
value = Homebrew::EnvConfig.send(method_name)
next unless value
if (default = hash[:default].presence)
next if value.to_s == default.to_s
end
if ENV.sensitive?(env)
f.puts "#{env}: set"
else
f.puts "#{env}: #{value}"
end
end
f.puts hardware if hardware
f.puts "Homebrew Ruby: #{describe_homebrew_ruby}"
f.print "Clang: "

View File

@ -272,7 +272,7 @@ class Tap
begin
safe_system "git", *args
unless Readall.valid_tap?(self, aliases: true)
raise "Cannot tap #{name}: invalid syntax in tap!" unless ARGV.homebrew_developer?
raise "Cannot tap #{name}: invalid syntax in tap!" unless Homebrew::EnvConfig.developer?
end
rescue Interrupt, RuntimeError
ignore_interrupts do
@ -641,12 +641,9 @@ class CoreTap < Tap
end
def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil)
if HOMEBREW_CORE_GIT_REMOTE != default_remote
puts "HOMEBREW_CORE_GIT_REMOTE set: using #{HOMEBREW_CORE_GIT_REMOTE} " \
"for Homebrew/core Git remote URL."
clone_target ||= HOMEBREW_CORE_GIT_REMOTE
end
super(full_clone: full_clone, quiet: quiet, clone_target: clone_target, force_auto_update: force_auto_update)
remote = Homebrew::EnvConfig.core_git_remote
puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} for Homebrew/core Git remote URL." if remote != default_remote
super(full_clone: full_clone, quiet: quiet, clone_target: remote, force_auto_update: force_auto_update)
end
# @private

View File

@ -13,8 +13,7 @@ describe Homebrew::CLI::Parser do
}
before do
allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("HOMEBREW_PRY").and_return("1")
allow(Homebrew::EnvConfig).to receive(:pry?).and_return(true)
end
it "parses short option" do
@ -181,18 +180,16 @@ describe Homebrew::CLI::Parser do
end
it "prioritizes cli arguments over env vars when they conflict" do
allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1")
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return(nil)
allow(Homebrew::EnvConfig).to receive(:switch_a?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:switch_b?).and_return(false)
parser.parse(["--switch-b"])
expect(Homebrew.args.switch_a).to be_falsy
expect(Homebrew.args).to be_switch_b
end
it "raises an exception on constraint violation when both are env vars" do
allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1")
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return("1")
allow(Homebrew::EnvConfig).to receive(:switch_a?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:switch_b?).and_return(true)
expect { parser.parse([]) }.to raise_error(Homebrew::CLI::OptionConflictError)
end
end

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
require "emoji"
describe Emoji do
describe "#install_badge" do
subject { described_class.install_badge }
before do
ENV.delete("HOMEBREW_INSTALL_BADGE")
end
it "returns 🍺 by default" do
expect(subject).to eq "🍺"
end
it "returns the contents of HOMEBREW_INSTALL_BADGE if set" do
ENV["HOMEBREW_INSTALL_BADGE"] = "foo"
expect(subject).to eq "foo"
end
end
end

View File

@ -26,7 +26,8 @@ describe Utils::Bottles::Collector do
end
it "does not use older tags when requested not to", :needs_macos do
allow(ARGV).to receive(:skip_or_later_bottles?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:developer?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
allow(OS::Mac).to receive(:prerelease?).and_return(true)
subject[:mavericks] = "foo"
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true
require "emoji"
require "utils/analytics"
require "utils/curl"
require "utils/fork"
@ -177,7 +176,7 @@ module Kernel
message << tap_message if tap_message
message.freeze
if ARGV.homebrew_developer? || disable || Homebrew.raise_deprecation_exceptions?
if Homebrew::EnvConfig.developer? || disable || Homebrew.raise_deprecation_exceptions?
exception = MethodDeprecatedError.new(message)
exception.set_backtrace(backtrace)
raise exception
@ -194,20 +193,20 @@ module Kernel
def pretty_installed(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
"#{Tty.bold}#{f} #{Formatter.success("")}#{Tty.reset}"
else
elsif Homebrew::EnvConfig.no_emoji?
Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
else
"#{Tty.bold}#{f} #{Formatter.success("")}#{Tty.reset}"
end
end
def pretty_uninstalled(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
"#{Tty.bold}#{f} #{Formatter.error("")}#{Tty.reset}"
else
elsif Homebrew::EnvConfig.no_emoji?
Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
else
"#{Tty.bold}#{f} #{Formatter.error("")}#{Tty.reset}"
end
end
@ -304,10 +303,7 @@ module Kernel
end
def which_editor
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL")
.compact
.reject(&:empty?)
.first
editor = Homebrew::EnvConfig.editor
return editor if editor
# Find Atom, Sublime Text, Textmate, BBEdit / TextWrangler, or vim
@ -331,11 +327,11 @@ module Kernel
end
def exec_browser(*args)
browser = ENV["HOMEBREW_BROWSER"]
browser = Homebrew::EnvConfig.browser
browser ||= OS::PATH_OPEN if defined?(OS::PATH_OPEN)
return unless browser
ENV["DISPLAY"] = ENV["HOMEBREW_DISPLAY"]
ENV["DISPLAY"] = Homebrew::EnvConfig.display
safe_system(browser, *args)
end

View File

@ -12,7 +12,7 @@ module Utils
args = []
# do not load .curlrc unless requested (must be the first argument)
args << "--disable" unless ENV["HOMEBREW_CURLRC"]
args << "--disable" unless Homebrew::EnvConfig.curlrc?
args += %W[
--max-time 3
@ -78,7 +78,7 @@ module Utils
end
def disabled?
return true if ENV["HOMEBREW_NO_ANALYTICS"]
return true if Homebrew::EnvConfig.no_analytics?
config_true?(:analyticsdisabled)
end
@ -308,7 +308,7 @@ module Utils
end
def formulae_api_json(endpoint)
return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_GITHUB_API"]
return if Homebrew::EnvConfig.no_analytics? || Homebrew::EnvConfig.no_github_api?
output, = curl_output("--max-time", "5",
"https://formulae.brew.sh/api/#{endpoint}")

View File

@ -17,7 +17,7 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
args = []
# do not load .curlrc unless requested (must be the first argument)
args << "--disable" unless ENV["HOMEBREW_CURLRC"]
args << "--disable" unless Homebrew::EnvConfig.curlrc?
args << "--globoff"
@ -35,12 +35,11 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
unless show_output
args << "--fail"
args << "--progress-bar" unless Homebrew.args.verbose?
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
args << "--silent" unless $stdout.tty?
end
# When changing the default value, the manpage has to be updated.
args << "--retry" << (ENV["HOMEBREW_CURL_RETRIES"] || "3")
args << "--retry" << Homebrew::EnvConfig.curl_retries
args + extra_args
end
@ -128,7 +127,7 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
return "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
end
if url.start_with?("https://") && ENV["HOMEBREW_NO_INSECURE_REDIRECT"] &&
if url.start_with?("https://") && Homebrew::EnvConfig.no_insecure_redirect? &&
!details[:final_url].start_with?("https://")
return "The URL #{url} redirects back to HTTP"
end

View File

@ -103,11 +103,15 @@ module Utils
quiet_system "git", "ls-remote", url
end
def self.set_git_name_email!
return unless ENV["HOMEBREW_GIT_NAME"]
return unless ENV["HOMEBREW_GIT_EMAIL"]
def self.set_git_name_email!(author: true, committer: true)
if Homebrew::EnvConfig.git_name
ENV["GIT_AUTHOR_NAME"] = Homebrew::EnvConfig.git_name if author
ENV["GIT_COMMITTER_NAME"] = Homebrew::EnvConfig.git_name if committer
end
ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"]
ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] = ENV["HOMEBREW_GIT_EMAIL"]
return unless Homebrew::EnvConfig.git_email
ENV["GIT_AUTHOR_EMAIL"] = Homebrew::EnvConfig.git_email if author
ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer
end
end

View File

@ -49,7 +49,7 @@ module GitHub
def initialize(github_message)
@github_message = github_message
message = +"GitHub #{github_message}:"
message << if ENV["HOMEBREW_GITHUB_API_TOKEN"]
message << if Homebrew::EnvConfig.github_api_token
<<~EOS
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
#{Formatter.url("https://github.com/settings/tokens")}
@ -80,15 +80,11 @@ module GitHub
end
end
def env_token
ENV["HOMEBREW_GITHUB_API_TOKEN"].presence
end
def env_username_password
return if ENV["HOMEBREW_GITHUB_API_USERNAME"].blank?
return if ENV["HOMEBREW_GITHUB_API_PASSWORD"].blank?
return unless Homebrew::EnvConfig.github_api_username
return unless Homebrew::EnvConfig.github_api_password
[ENV["HOMEBREW_GITHUB_API_PASSWORD"], ENV["HOMEBREW_GITHUB_API_USERNAME"]]
[Homebrew::EnvConfig.github_api_password, Homebrew::EnvConfig.github_api_username]
end
def keychain_username_password
@ -117,12 +113,12 @@ module GitHub
def api_credentials
@api_credentials ||= begin
env_token || env_username_password || keychain_username_password
Homebrew::EnvConfig.github_api_token || env_username_password || keychain_username_password
end
end
def api_credentials_type
if env_token
if Homebrew::EnvConfig.github_api_token
:env_token
elsif env_username_password
:env_username_password
@ -174,7 +170,7 @@ module GitHub
def open_api(url, data: nil, request_method: nil, scopes: [].freeze, parse_json: true)
# This is a no-op if the user is opting out of using the GitHub API.
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]
return block_given? ? yield({}) : {} if Homebrew::EnvConfig.no_github_api?
args = ["--header", "Accept: application/vnd.github.v3+json", "--write-out", "\n%\{http_code}"]
args += ["--header", "Accept: application/vnd.github.antiope-preview+json"]

View File

@ -72,8 +72,8 @@ module Tty
end
def color?
return false if ENV["HOMEBREW_NO_COLOR"]
return true if ENV["HOMEBREW_COLOR"]
return false if Homebrew::EnvConfig.no_color?
return true if Homebrew::EnvConfig.color?
$stdout.tty?
end

View File

@ -62,8 +62,7 @@ HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
# Whitelist and copy to HOMEBREW_* all variables previously mentioned in
# manpage or used elsewhere by Homebrew.
for VAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY BINTRAY_USER BINTRAY_KEY \
BROWSER DISPLAY EDITOR GIT NO_COLOR PATH VISUAL
for VAR in BROWSER DISPLAY EDITOR NO_COLOR PATH
do
# Skip if variable value is empty.
[[ -z "${!VAR}" ]] && continue
@ -74,6 +73,12 @@ do
export "$VAR_NEW"="${!VAR}"
done
# Use VISUAL if HOMEBREW_EDITOR and EDITOR are unset.
if [[ -z "$HOMEBREW_EDITOR" && -n "$VISUAL" ]]
then
export HOMEBREW_EDITOR="$VISUAL"
fi
# Set CI variable for GitHub Actions, Azure Pipelines, Jenkins
# (Set by default on Circle and Travis CI)
if [[ -n "$GITHUB_ACTIONS" || -n "$TF_BUILD" || -n "$JENKINS_HOME" ]]
@ -90,7 +95,7 @@ then
# Filter all but the specific variables.
for VAR in HOME SHELL PATH TERM TERMINFO COLUMNS DISPLAY LOGNAME USER CI SSH_AUTH_SOCK SUDO_ASKPASS \
http_proxy https_proxy ftp_proxy no_proxy all_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY \
"${!HOMEBREW_@}" "${!TRAVIS_@}"
"${!HOMEBREW_@}"
do
# Skip if variable value is empty.
[[ -z "${!VAR}" ]] && continue