Replace #chuzzle with ActiveSupport’s #presence.
This commit is contained in:
parent
16618d0fc7
commit
5dd571adeb
@ -18,17 +18,17 @@ module Homebrew
|
|||||||
|
|
||||||
case ARGV.named.first
|
case ARGV.named.first
|
||||||
when nil, "state"
|
when nil, "state"
|
||||||
analyticsdisabled = \
|
analyticsdisabled =
|
||||||
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chuzzle
|
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp
|
||||||
uuid = \
|
uuid =
|
||||||
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chuzzle
|
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chomp
|
||||||
if ENV["HOMEBREW_NO_ANALYTICS"]
|
if ENV["HOMEBREW_NO_ANALYTICS"]
|
||||||
puts "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)."
|
puts "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)."
|
||||||
elsif analyticsdisabled == "true"
|
elsif analyticsdisabled == "true"
|
||||||
puts "Analytics is disabled."
|
puts "Analytics is disabled."
|
||||||
else
|
else
|
||||||
puts "Analytics is enabled."
|
puts "Analytics is enabled."
|
||||||
puts "UUID: #{uuid}" if uuid
|
puts "UUID: #{uuid}" if uuid.present?
|
||||||
end
|
end
|
||||||
when "on"
|
when "on"
|
||||||
safe_system "git", "config", "--file=#{config_file}",
|
safe_system "git", "config", "--file=#{config_file}",
|
||||||
|
|||||||
@ -22,14 +22,14 @@ module Homebrew
|
|||||||
def update_report
|
def update_report
|
||||||
HOMEBREW_REPOSITORY.cd do
|
HOMEBREW_REPOSITORY.cd do
|
||||||
analytics_message_displayed =
|
analytics_message_displayed =
|
||||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle
|
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chomp == "true"
|
||||||
cask_analytics_message_displayed =
|
cask_analytics_message_displayed =
|
||||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.caskanalyticsmessage").chuzzle
|
Utils.popen_read("git", "config", "--local", "--get", "homebrew.caskanalyticsmessage").chomp == "true"
|
||||||
analytics_disabled =
|
analytics_disabled =
|
||||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle
|
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chomp == "true"
|
||||||
if analytics_message_displayed != "true" &&
|
if !analytics_message_displayed &&
|
||||||
cask_analytics_message_displayed != "true" &&
|
!cask_analytics_message_displayed &&
|
||||||
analytics_disabled != "true" &&
|
!analytics_disabled &&
|
||||||
!ENV["HOMEBREW_NO_ANALYTICS"] &&
|
!ENV["HOMEBREW_NO_ANALYTICS"] &&
|
||||||
!ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"]
|
!ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"]
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
donation_message_displayed =
|
donation_message_displayed =
|
||||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.donationmessage").chuzzle
|
Utils.popen_read("git", "config", "--local", "--get", "homebrew.donationmessage").chomp == "true"
|
||||||
if donation_message_displayed != "true"
|
unless donation_message_displayed
|
||||||
ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:"
|
ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:"
|
||||||
puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n"
|
puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n"
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ module GitRepositoryExtension
|
|||||||
def git_origin
|
def git_origin
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chuzzle
|
Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_origin=(origin)
|
def git_origin=(origin)
|
||||||
@ -21,30 +21,30 @@ module GitRepositoryExtension
|
|||||||
def git_head
|
def git_head
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chuzzle
|
Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_short_head
|
def git_short_head
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chuzzle
|
Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_last_commit
|
def git_last_commit
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chuzzle
|
Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_branch
|
def git_branch
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chuzzle
|
Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_last_commit_date
|
def git_last_commit_date
|
||||||
return unless git? && Utils.git_available?
|
return unless git? && Utils.git_available?
|
||||||
|
|
||||||
Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chuzzle
|
Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chomp.presence
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
# Contains backports from newer versions of Ruby
|
# Contains backports from newer versions of Ruby
|
||||||
require "backports/2.4.0/string/match"
|
require "backports/2.4.0/string/match"
|
||||||
require "backports/2.5.0/string/delete_prefix"
|
require "backports/2.5.0/string/delete_prefix"
|
||||||
|
require "active_support/core_ext/object/blank"
|
||||||
|
|
||||||
class String
|
class String
|
||||||
# String.chomp, but if result is empty: returns nil instead.
|
# String.chomp, but if result is empty: returns nil instead.
|
||||||
# Allows `chuzzle || foo` short-circuits.
|
# Allows `chuzzle || foo` short-circuits.
|
||||||
|
# TODO: Deprecate.
|
||||||
def chuzzle
|
def chuzzle
|
||||||
s = chomp
|
s = chomp
|
||||||
s unless s.empty?
|
s unless s.empty?
|
||||||
@ -12,6 +14,7 @@ class String
|
|||||||
end
|
end
|
||||||
|
|
||||||
class NilClass
|
class NilClass
|
||||||
|
# TODO: Deprecate.
|
||||||
def chuzzle; end
|
def chuzzle; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ require "pp"
|
|||||||
|
|
||||||
require_relative "load_path"
|
require_relative "load_path"
|
||||||
|
|
||||||
|
require "active_support/core_ext/object/blank"
|
||||||
require "active_support/core_ext/numeric/time"
|
require "active_support/core_ext/numeric/time"
|
||||||
require "active_support/core_ext/array/access"
|
require "active_support/core_ext/array/access"
|
||||||
require "active_support/i18n"
|
require "active_support/i18n"
|
||||||
|
|||||||
@ -722,7 +722,7 @@ class TapConfig
|
|||||||
return unless Utils.git_available?
|
return unless Utils.git_available?
|
||||||
|
|
||||||
tap.path.cd do
|
tap.path.cd do
|
||||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.#{key}").chuzzle
|
Utils.popen_read("git", "config", "--local", "--get", "homebrew.#{key}").chomp.presence
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ module Utils
|
|||||||
|
|
||||||
@git_path ||= Utils.popen_read(
|
@git_path ||= Utils.popen_read(
|
||||||
HOMEBREW_SHIMS_PATH/"scm/git", "--homebrew=print-path"
|
HOMEBREW_SHIMS_PATH/"scm/git", "--homebrew=print-path"
|
||||||
).chuzzle
|
).chomp.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.git_version
|
def self.git_version
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user