Improve Homebrew/brew line length.

Use 124 max line length everywhere. Also, reduce tap max line length to
189 as Homebrew/homebrew-core has that as a maximum now. In future
Homebrew/homebrew-core will also be reduced to 124 maximum line length.
This commit is contained in:
Mike McQuaid 2018-09-02 16:15:09 +01:00
parent 5869842e7e
commit bcb1ec5499
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
57 changed files with 523 additions and 200 deletions

View File

@ -73,8 +73,8 @@ Metrics/CyclomaticComplexity:
Enabled: false Enabled: false
Metrics/LineLength: Metrics/LineLength:
# 124 is the goal as GitHub diff UI wraps beyond that # 118 is the goal as GitHub diff UI wraps beyond that
Max: 190 Max: 189
# ignore manpage comments and long single-line strings # ignore manpage comments and long single-line strings
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options :'] IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options :']

View File

@ -51,8 +51,8 @@ Metrics/CyclomaticComplexity:
Max: 75 Max: 75
Metrics/LineLength: Metrics/LineLength:
# 124 is the goal as GitHub diff UI wraps beyond that # 118 is the goal as GitHub diff UI wraps beyond that
Max: 244 Max: 118
# ignore manpage comments # ignore manpage comments
IgnoredPatterns: ['#: '] IgnoredPatterns: ['#: ']

View File

@ -65,7 +65,8 @@ class BuildOptions
include? "devel" include? "devel"
end end
# True if a {Formula} is being built with {Formula.stable} instead of {Formula.devel} or {Formula.head}. This is the default. # True if a {Formula} is being built with {Formula.stable} instead of {Formula.devel}
# or {Formula.head}. This is the default.
# <pre>args << "--some-beta" if build.devel?</pre> # <pre>args << "--some-beta" if build.devel?</pre>
def stable? def stable?
!(head? || devel?) !(head? || devel?)

View File

@ -72,7 +72,9 @@ module Hbc
permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :print_stdout, :print_stderr] permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :print_stdout, :print_stderr]
unknown_keys = arguments.keys - permitted_keys unknown_keys = arguments.keys - permitted_keys
unless unknown_keys.empty? unless unknown_keys.empty?
opoo %Q{Unknown arguments to #{description} -- #{unknown_keys.inspect} (ignored). Running "brew update; brew cleanup" will likely fix it.} opoo "Unknown arguments to #{description} -- " \
"#{unknown_keys.inspect} (ignored). Running " \
"\"brew update; brew cleanup\" will likely fix it."
end end
arguments.select! { |k| permitted_keys.include?(k) } arguments.select! { |k| permitted_keys.include?(k) }

View File

@ -66,7 +66,8 @@ module Hbc
def warn_for_unknown_directives(directives) def warn_for_unknown_directives(directives)
unknown_keys = directives.keys - ORDERED_DIRECTIVES unknown_keys = directives.keys - ORDERED_DIRECTIVES
return if unknown_keys.empty? return if unknown_keys.empty?
opoo %Q(Unknown arguments to #{stanza} -- #{unknown_keys.inspect}. Running "brew update; brew cleanup" will likely fix it.) opoo "Unknown arguments to #{stanza} -- #{unknown_keys.inspect}. " \
"Running \"brew update; brew cleanup\" will likely fix it."
end end
# Preserve prior functionality of script which runs first. Should rarely be needed. # Preserve prior functionality of script which runs first. Should rarely be needed.
@ -81,7 +82,11 @@ module Hbc
services.each do |service| services.each do |service|
ohai "Removing launchctl service #{service}" ohai "Removing launchctl service #{service}"
[false, true].each do |with_sudo| [false, true].each do |with_sudo|
plist_status = command.run("/bin/launchctl", args: ["list", service], sudo: with_sudo, print_stderr: false).stdout plist_status = command.run(
"/bin/launchctl",
args: ["list", service],
sudo: with_sudo, print_stderr: false
).stdout
if plist_status =~ /^\{/ if plist_status =~ /^\{/
command.run!("/bin/launchctl", args: ["remove", service], sudo: with_sudo) command.run!("/bin/launchctl", args: ["remove", service], sudo: with_sudo)
sleep 1 sleep 1
@ -157,9 +162,14 @@ module Hbc
def uninstall_login_item(*login_items, command: nil, **_) def uninstall_login_item(*login_items, command: nil, **_)
login_items.each do |name| login_items.each do |name|
ohai "Removing login item #{name}" ohai "Removing login item #{name}"
command.run!("/usr/bin/osascript", command.run!(
args: ["-e", %Q(tell application "System Events" to delete every login item whose name is "#{name}")], "/usr/bin/osascript",
sudo: false) args: [
"-e",
%Q(tell application "System Events" to delete every login item whose name is "#{name}"),
],
sudo: false,
)
sleep 1 sleep 1
end end
end end
@ -243,7 +253,12 @@ module Hbc
ohai "Removing files:" ohai "Removing files:"
each_resolved_path(:delete, paths) do |path, resolved_paths| each_resolved_path(:delete, paths) do |path, resolved_paths|
puts path puts path
command.run!("/usr/bin/xargs", args: ["-0", "--", "/bin/rm", "-r", "-f", "--"], input: resolved_paths.join("\0"), sudo: true) command.run!(
"/usr/bin/xargs",
args: ["-0", "--", "/bin/rm", "-r", "-f", "--"],
input: resolved_paths.join("\0"),
sudo: true,
)
end end
end end

View File

@ -42,7 +42,13 @@ module Hbc
path path
end end
command.run!(executable, **args, env: { "PATH" => PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]) }) command.run!(
executable,
**args,
env: { "PATH" => PATH.new(
HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]
) },
)
end end
end end
@ -60,7 +66,10 @@ module Hbc
end end
unless args.keys.count == 1 unless args.keys.count == 1
raise CaskInvalidError.new(cask, "invalid 'installer' stanza: Only one of #{VALID_KEYS.inspect} is permitted.") raise CaskInvalidError.new(
cask,
"invalid 'installer' stanza: Only one of #{VALID_KEYS.inspect} is permitted.",
)
end end
args.assert_valid_keys!(*VALID_KEYS) args.assert_valid_keys!(*VALID_KEYS)

View File

@ -27,7 +27,8 @@ module Hbc
def move(force: false, command: nil, **options) def move(force: false, command: nil, **options)
if Utils.path_occupied?(target) if Utils.path_occupied?(target)
message = "It seems there is already #{self.class.english_article} #{self.class.english_name} at '#{target}'" message = "It seems there is already #{self.class.english_article} " \
"#{self.class.english_name} at '#{target}'"
raise CaskError, "#{message}." unless force raise CaskError, "#{message}." unless force
opoo "#{message}; overwriting." opoo "#{message}; overwriting."
delete(target, force: force, command: command, **options) delete(target, force: force, command: command, **options)
@ -51,7 +52,8 @@ module Hbc
def move_back(skip: false, force: false, command: nil, **options) def move_back(skip: false, force: false, command: nil, **options)
if Utils.path_occupied?(source) if Utils.path_occupied?(source)
message = "It seems there is already #{self.class.english_article} #{self.class.english_name} at '#{source}'" message = "It seems there is already #{self.class.english_article} " \
"#{self.class.english_name} at '#{source}'"
raise CaskError, "#{message}." unless force raise CaskError, "#{message}." unless force
opoo "#{message}; overwriting." opoo "#{message}; overwriting."
delete(source, force: force, command: command, **options) delete(source, force: force, command: command, **options)

View File

@ -37,11 +37,15 @@ module Hbc
def link(**options) def link(**options)
unless source.exist? unless source.exist?
raise CaskError, "It seems the #{self.class.link_type_english_name.downcase} source '#{source}' is not there." raise CaskError,
"It seems the #{self.class.link_type_english_name.downcase} " \
"source '#{source}' is not there."
end end
if target.exist? && !target.symlink? if target.exist? && !target.symlink?
raise CaskError, "It seems there is already #{self.class.english_article} #{self.class.english_name} at '#{target}'; not linking." raise CaskError,
"It seems there is already #{self.class.english_article} " \
"#{self.class.english_name} at '#{target}'; not linking."
end end
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'." ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'."

View File

@ -83,7 +83,12 @@ module Hbc
add_warning "only a single preflight stanza is allowed" add_warning "only a single preflight stanza is allowed"
end end
return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:postflight) } > 1 count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PostflightBlock) &&
k.directives.key?(:postflight)
end
return unless count > 1
add_warning "only a single postflight stanza is allowed" add_warning "only a single postflight stanza is allowed"
end end
@ -94,11 +99,21 @@ module Hbc
add_warning "only a single uninstall stanza is allowed" add_warning "only a single uninstall stanza is allowed"
end end
if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:uninstall_preflight) } > 1 count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PreflightBlock) &&
k.directives.key?(:uninstall_preflight)
end
if count > 1
add_warning "only a single uninstall_preflight stanza is allowed" add_warning "only a single uninstall_preflight stanza is allowed"
end end
if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:uninstall_postflight) } > 1 count = cask.artifacts.count do |k|
k.is_a?(Hbc::Artifact::PostflightBlock) &&
k.directives.key?(:uninstall_postflight)
end
if count > 1
add_warning "only a single uninstall_postflight stanza is allowed" add_warning "only a single uninstall_postflight stanza is allowed"
end end

View File

@ -135,10 +135,14 @@ module Hbc
def self.check_sip def self.check_sip
csrutil = "/usr/bin/csrutil" csrutil = "/usr/bin/csrutil"
return "N/A" unless File.executable?(csrutil) return "N/A" unless File.executable?(csrutil)
Open3.capture2(csrutil, "status")[0] Open3.capture2(csrutil, "status")
.gsub("This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.", "") .first
.gsub("This is an unsupported configuration, likely to break in " \
"the future and leave your machine in an unknown state.", "")
.gsub("System Integrity Protection status: ", "") .gsub("System Integrity Protection status: ", "")
.delete("\t\.").capitalize.strip .delete("\t\.")
.capitalize
.strip
end end
def self.locale_variables def self.locale_variables

View File

@ -263,7 +263,8 @@ module Hbc
ORDINARY_ARTIFACT_CLASSES.each do |klass| ORDINARY_ARTIFACT_CLASSES.each do |klass|
define_method(klass.dsl_key) do |*args| define_method(klass.dsl_key) do |*args|
begin begin
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) && (artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any? if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.") raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
end end

View File

@ -241,15 +241,23 @@ module Hbc
if @cask.depends_on.macos.first.is_a?(Array) if @cask.depends_on.macos.first.is_a?(Array)
operator, release = @cask.depends_on.macos.first operator, release = @cask.depends_on.macos.first
unless MacOS.version.send(operator, release) unless MacOS.version.send(operator, release)
raise CaskError, "Cask #{@cask} depends on macOS release #{operator} #{release}, but you are running release #{MacOS.version}." raise CaskError,
"Cask #{@cask} depends on macOS release #{operator} #{release}, " \
"but you are running release #{MacOS.version}."
end end
elsif @cask.depends_on.macos.length > 1 elsif @cask.depends_on.macos.length > 1
unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.version.to_s)) unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.version.to_s))
raise CaskError, "Cask #{@cask} depends on macOS release being one of [#{@cask.depends_on.macos.map(&:to_s).join(", ")}], but you are running release #{MacOS.version}." raise CaskError,
"Cask #{@cask} depends on macOS release being one of " \
"[#{@cask.depends_on.macos.map(&:to_s).join(", ")}], " \
"but you are running release #{MacOS.version}."
end end
else else
unless MacOS.version == @cask.depends_on.macos.first unless MacOS.version == @cask.depends_on.macos.first
raise CaskError, "Cask #{@cask} depends on macOS release #{@cask.depends_on.macos.first}, but you are running release #{MacOS.version}." raise CaskError,
"Cask #{@cask} depends on macOS release " \
"#{@cask.depends_on.macos.first}, " \
"but you are running release #{MacOS.version}."
end end
end end
end end
@ -261,7 +269,10 @@ module Hbc
arch[:type] == @current_arch[:type] && arch[:type] == @current_arch[:type] &&
Array(arch[:bits]).include?(@current_arch[:bits]) Array(arch[:bits]).include?(@current_arch[:bits])
end end
raise CaskError, "Cask #{@cask} depends on hardware architecture being one of [#{@cask.depends_on.arch.map(&:to_s).join(", ")}], but you are running #{@current_arch}" raise CaskError,
"Cask #{@cask} depends on hardware architecture being one of " \
"[#{@cask.depends_on.arch.map(&:to_s).join(", ")}], " \
"but you are running #{@current_arch}"
end end
def x11_dependencies def x11_dependencies
@ -307,7 +318,13 @@ module Hbc
ohai "Installing Cask dependencies: #{not_installed.map(&:to_s).join(", ")}" ohai "Installing Cask dependencies: #{not_installed.map(&:to_s).join(", ")}"
not_installed.each do |cask| not_installed.each do |cask|
Installer.new(cask, binaries: binaries?, verbose: verbose?, installed_as_dependency: true, force: false).install Installer.new(
cask,
binaries: binaries?,
verbose: verbose?,
installed_as_dependency: true,
force: false,
).install
end end
end end
@ -349,23 +366,31 @@ module Hbc
return unless @cask.accessibility_access return unless @cask.accessibility_access
ohai "Enabling accessibility access" ohai "Enabling accessibility access"
if MacOS.version <= :mountain_lion if MacOS.version <= :mountain_lion
@command.run!("/usr/bin/touch", @command.run!(
args: [MacOS.pre_mavericks_accessibility_dotfile], "/usr/bin/touch",
sudo: true) args: [MacOS.pre_mavericks_accessibility_dotfile],
sudo: true,
)
elsif MacOS.version <= :yosemite elsif MacOS.version <= :yosemite
@command.run!("/usr/bin/sqlite3", @command.run!(
args: [ "/usr/bin/sqlite3",
MacOS.tcc_db, args: [
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);", MacOS.tcc_db,
], "INSERT OR REPLACE INTO access " \
sudo: true) "VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);",
],
sudo: true,
)
elsif MacOS.version <= :el_capitan elsif MacOS.version <= :el_capitan
@command.run!("/usr/bin/sqlite3", @command.run!(
args: [ "/usr/bin/sqlite3",
MacOS.tcc_db, args: [
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);", MacOS.tcc_db,
], "INSERT OR REPLACE INTO access " \
sudo: true) "VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);",
],
sudo: true,
)
else else
opoo <<~EOS opoo <<~EOS
Accessibility access cannot be enabled automatically on this version of macOS. Accessibility access cannot be enabled automatically on this version of macOS.

View File

@ -16,12 +16,26 @@ module Hbc
def uninstall def uninstall
unless pkgutil_bom_files.empty? unless pkgutil_bom_files.empty?
odebug "Deleting pkg files" odebug "Deleting pkg files"
@command.run!("/usr/bin/xargs", args: ["-0", "--", "/bin/rm", "--"], input: pkgutil_bom_files.join("\0"), sudo: true) @command.run!(
"/usr/bin/xargs",
args: [
"-0", "--", "/bin/rm", "--"
],
input: pkgutil_bom_files.join("\0"),
sudo: true,
)
end end
unless pkgutil_bom_specials.empty? unless pkgutil_bom_specials.empty?
odebug "Deleting pkg symlinks and special files" odebug "Deleting pkg symlinks and special files"
@command.run!("/usr/bin/xargs", args: ["-0", "--", "/bin/rm", "--"], input: pkgutil_bom_specials.join("\0"), sudo: true) @command.run!(
"/usr/bin/xargs",
args: [
"-0", "--", "/bin/rm", "--"
],
input: pkgutil_bom_specials.join("\0"),
sudo: true,
)
end end
unless pkgutil_bom_dirs.empty? unless pkgutil_bom_dirs.empty?

View File

@ -31,10 +31,14 @@ module Homebrew
PACKAGE_MANAGERS = { PACKAGE_MANAGERS = {
macports: ->(query) { "https://www.macports.org/ports.php?by=name&substr=#{query}" }, macports: ->(query) { "https://www.macports.org/ports.php?by=name&substr=#{query}" },
fink: ->(query) { "http://pdb.finkproject.org/pdb/browse.php?summary=#{query}" }, fink: ->(query) { "http://pdb.finkproject.org/pdb/browse.php?summary=#{query}" },
debian: ->(query) { "https://packages.debian.org/search?keywords=#{query}&searchon=names&suite=all&section=all" },
opensuse: ->(query) { "https://software.opensuse.org/search?q=#{query}" }, opensuse: ->(query) { "https://software.opensuse.org/search?q=#{query}" },
fedora: ->(query) { "https://apps.fedoraproject.org/packages/s/#{query}" }, fedora: ->(query) { "https://apps.fedoraproject.org/packages/s/#{query}" },
ubuntu: ->(query) { "https://packages.ubuntu.com/search?keywords=#{query}&searchon=names&suite=all&section=all" }, debian: lambda { |query|
"https://packages.debian.org/search?keywords=#{query}&searchon=names&suite=all&section=all"
},
ubuntu: lambda { |query|
"https://packages.ubuntu.com/search?keywords=#{query}&searchon=names&suite=all&section=all"
},
}.freeze }.freeze
def search(argv = ARGV) def search(argv = ARGV)

View File

@ -399,7 +399,10 @@ module Homebrew
if @new_formula && dep_f.keg_only_reason && if @new_formula && dep_f.keg_only_reason &&
!["openssl", "apr", "apr-util"].include?(dep.name) && !["openssl", "apr", "apr-util"].include?(dep.name) &&
dep_f.keg_only_reason.reason == :provided_by_macos dep_f.keg_only_reason.reason == :provided_by_macos
new_formula_problem "Dependency '#{dep.name}' may be unnecessary as it is provided by macOS; try to build this formula without it." new_formula_problem(
"Dependency '#{dep.name}' may be unnecessary as it is provided " \
"by macOS; try to build this formula without it.",
)
end end
dep.options.each do |opt| dep.options.each do |opt|
@ -572,7 +575,10 @@ module Homebrew
next if spec.patches.empty? next if spec.patches.empty?
next unless @new_formula next unless @new_formula
new_formula_problem "Formulae should not require patches to build. Patches should be submitted and accepted upstream first." new_formula_problem(
"Formulae should not require patches to build. " \
"Patches should be submitted and accepted upstream first.",
)
end end
%w[Stable Devel].each do |name| %w[Stable Devel].each do |name|
@ -693,7 +699,11 @@ module Homebrew
next unless spec = formula.send(spec_sym) next unless spec = formula.send(spec_sym)
next unless previous_version_and_checksum[spec_sym][:version] == spec.version next unless previous_version_and_checksum[spec_sym][:version] == spec.version
next if previous_version_and_checksum[spec_sym][:checksum] == spec.checksum next if previous_version_and_checksum[spec_sym][:checksum] == spec.checksum
problem "#{spec_sym}: sha256 changed without the version also changing; please create an issue upstream to rule out malicious circumstances and to find out why the file changed." problem(
"#{spec_sym}: sha256 changed without the version also changing; " \
"please create an issue upstream to rule out malicious " \
"circumstances and to find out why the file changed.",
)
end end
attributes = [:revision, :version_scheme] attributes = [:revision, :version_scheme]
@ -795,7 +805,10 @@ module Homebrew
# Prefer formula path shortcuts in Pathname+ # Prefer formula path shortcuts in Pathname+
if line =~ %r{\(\s*(prefix\s*\+\s*(['"])(bin|include|libexec|lib|sbin|share|Frameworks)[/'"])} if line =~ %r{\(\s*(prefix\s*\+\s*(['"])(bin|include|libexec|lib|sbin|share|Frameworks)[/'"])}
problem "\"(#{Regexp.last_match(1)}...#{Regexp.last_match(2)})\" should be \"(#{Regexp.last_match(3).downcase}+...)\"" problem(
"\"(#{Regexp.last_match(1)}...#{Regexp.last_match(2)})\" should" \
" be \"(#{Regexp.last_match(3).downcase}+...)\"",
)
end end
problem "Use separate make calls" if line.include?("make && make") problem "Use separate make calls" if line.include?("make && make")

View File

@ -178,48 +178,87 @@ module Homebrew
replacement_pairs = [] replacement_pairs = []
if requested_spec == :stable && formula.revision.nonzero? if requested_spec == :stable && formula.revision.nonzero?
replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"] replacement_pairs << [
/^ revision \d+\n(\n( head "))?/m,
"\\2",
]
end end
replacement_pairs += formula_spec.mirrors.map do |mirror| replacement_pairs += formula_spec.mirrors.map do |mirror|
[/ +mirror \"#{Regexp.escape(mirror)}\"\n/m, ""] [
/ +mirror \"#{Regexp.escape(mirror)}\"\n/m,
"",
]
end end
replacement_pairs += if new_url_hash replacement_pairs += if new_url_hash
[ [
[/#{Regexp.escape(formula_spec.url)}/, new_url], [
[old_hash, new_hash], /#{Regexp.escape(formula_spec.url)}/,
new_url,
],
[
old_hash,
new_hash,
],
] ]
else else
[ [
[formula_spec.specs[:tag], new_tag], [
[formula_spec.specs[:revision], new_revision], formula_spec.specs[:tag],
new_tag,
],
[
formula_spec.specs[:revision],
new_revision,
],
] ]
end end
backup_file = File.read(formula.path) unless args.dry_run? backup_file = File.read(formula.path) unless args.dry_run?
if new_mirror if new_mirror
replacement_pairs << [/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"] replacement_pairs << [
/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m,
"\\1\\2\\1mirror \"#{new_mirror}\"\n",
]
end end
if forced_version && forced_version != "0" if forced_version && forced_version != "0"
if requested_spec == :stable if requested_spec == :stable
if File.read(formula.path).include?("version \"#{old_formula_version}\"") if File.read(formula.path).include?("version \"#{old_formula_version}\"")
replacement_pairs << [old_formula_version.to_s, forced_version] replacement_pairs << [
old_formula_version.to_s,
forced_version,
]
elsif new_mirror elsif new_mirror
replacement_pairs << [/^( +)(mirror \"#{new_mirror}\"\n)/m, "\\1\\2\\1version \"#{forced_version}\"\n"] replacement_pairs << [
/^( +)(mirror \"#{new_mirror}\"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n",
]
else else
replacement_pairs << [/^( +)(url \"#{new_url}\"\n)/m, "\\1\\2\\1version \"#{forced_version}\"\n"] replacement_pairs << [
/^( +)(url \"#{new_url}\"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n",
]
end end
elsif requested_spec == :devel elsif requested_spec == :devel
replacement_pairs << [/( devel do.+?version \")#{old_formula_version}(\"\n.+?end\n)/m, "\\1#{forced_version}\\2"] replacement_pairs << [
/( devel do.+?version \")#{old_formula_version}(\"\n.+?end\n)/m,
"\\1#{forced_version}\\2",
]
end end
elsif forced_version && forced_version == "0" elsif forced_version && forced_version == "0"
if requested_spec == :stable if requested_spec == :stable
replacement_pairs << [/^ version \"[\w\.\-\+]+\"\n/m, ""] replacement_pairs << [
/^ version \"[\w\.\-\+]+\"\n/m,
"",
]
elsif requested_spec == :devel elsif requested_spec == :devel
replacement_pairs << [/( devel do.+?)^ +version \"[^\n]+\"\n(.+?end\n)/m, "\\1\\2"] replacement_pairs << [
/( devel do.+?)^ +version \"[^\n]+\"\n(.+?end\n)/m,
"\\1\\2",
]
end end
end end
new_contents = inreplace_pairs(formula.path, replacement_pairs) new_contents = inreplace_pairs(formula.path, replacement_pairs)
@ -270,7 +309,8 @@ module Homebrew
ohai "fork repository with GitHub API" ohai "fork repository with GitHub API"
ohai "git fetch --unshallow origin" if shallow ohai "git fetch --unshallow origin" if shallow
ohai "git checkout --no-track -b #{branch} origin/master" ohai "git checkout --no-track -b #{branch} origin/master"
ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}" ohai "git commit --no-edit --verbose --message='#{formula.name} " \
"#{new_formula_version}#{devel_message}' -- #{formula.path}"
ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}" ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}"
ohai "create pull request with GitHub API" ohai "create pull request with GitHub API"
ohai "git checkout -" ohai "git checkout -"

View File

@ -79,7 +79,11 @@ module Homebrew
# unless --force is specified. # unless --force is specified.
unless args.force? unless args.force?
if reason = MissingFormula.blacklisted_reason(fc.name) if reason = MissingFormula.blacklisted_reason(fc.name)
raise "#{fc.name} is blacklisted for creation.\n#{reason}\nIf you really want to create this formula use --force." raise <<~EOS
#{fc.name} is blacklisted for creation.
#{reason}
If you really want to create this formula use --force.
EOS
end end
if Formula.aliases.include? fc.name if Formula.aliases.include? fc.name

View File

@ -66,18 +66,24 @@ module Homebrew
variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}") variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}")
variables[:developer_commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}") variables[:developer_commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}")
readme = HOMEBREW_REPOSITORY/"README.md" readme = HOMEBREW_REPOSITORY/"README.md"
variables[:lead_maintainer] = readme.read[/(Homebrew's lead maintainer .*\.)/, 1] variables[:lead_maintainer] =
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') readme.read[/(Homebrew's lead maintainer .*\.)/, 1]
variables[:leadership] = readme.read[/(Homebrew's project leadership committee .*\.)/, 1] .gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') variables[:leadership] =
variables[:brew_maintainers] = readme.read[%r{(Homebrew/brew's other current maintainers .*\.)}, 1] readme.read[/(Homebrew's project leadership committee .*\.)/, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') .gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:linux_maintainers] = readme.read[%r{(Homebrew/brew's Linux support \(and Linuxbrew\) maintainers are .*\.)}, 1] variables[:brew_maintainers] =
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') readme.read[%r{(Homebrew/brew's other current maintainers .*\.)}, 1]
variables[:core_maintainers] = readme.read[%r{(Homebrew/homebrew-core's other current maintainers .*\.)}, 1] .gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') variables[:linux_maintainers] =
variables[:former_maintainers] = readme.read[/(Former maintainers .*\.)/, 1] readme.read[%r{(Homebrew/brew's Linux support \(and Linuxbrew\) maintainers are .*\.)}, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1') .gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:core_maintainers] =
readme.read[%r{(Homebrew/homebrew-core's other current maintainers .*\.)}, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:former_maintainers] =
readme.read[/(Former maintainers .*\.)/, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:homebrew_bundle] = help_output(:bundle) variables[:homebrew_bundle] = help_output(:bundle)
variables[:homebrew_services] = help_output(:services) variables[:homebrew_services] = help_output(:services)

View File

@ -1210,21 +1210,28 @@ class DownloadStrategyDetector
case url case url
when %r{^https?://github\.com/[^/]+/[^/]+\.git$} when %r{^https?://github\.com/[^/]+/[^/]+\.git$}
GitHubGitDownloadStrategy GitHubGitDownloadStrategy
when %r{^https?://.+\.git$}, %r{^git://} when %r{^https?://.+\.git$},
%r{^git://}
GitDownloadStrategy GitDownloadStrategy
when %r{^https?://www\.apache\.org/dyn/closer\.cgi}, %r{^https?://www\.apache\.org/dyn/closer\.lua} when %r{^https?://www\.apache\.org/dyn/closer\.cgi},
%r{^https?://www\.apache\.org/dyn/closer\.lua}
CurlApacheMirrorDownloadStrategy CurlApacheMirrorDownloadStrategy
when %r{^https?://(.+?\.)?googlecode\.com/svn}, %r{^https?://svn\.}, %r{^svn://}, %r{^https?://(.+?\.)?sourceforge\.net/svnroot/} when %r{^https?://(.+?\.)?googlecode\.com/svn},
%r{^https?://svn\.},
%r{^svn://},
%r{^https?://(.+?\.)?sourceforge\.net/svnroot/}
SubversionDownloadStrategy SubversionDownloadStrategy
when %r{^cvs://} when %r{^cvs://}
CVSDownloadStrategy CVSDownloadStrategy
when %r{^hg://}, %r{^https?://(.+?\.)?googlecode\.com/hg} when %r{^hg://},
%r{^https?://(.+?\.)?googlecode\.com/hg}
MercurialDownloadStrategy MercurialDownloadStrategy
when %r{^bzr://} when %r{^bzr://}
BazaarDownloadStrategy BazaarDownloadStrategy
when %r{^fossil://} when %r{^fossil://}
FossilDownloadStrategy FossilDownloadStrategy
when %r{^svn\+http://}, %r{^http://svn\.apache\.org/repos/} when %r{^svn\+http://},
%r{^http://svn\.apache\.org/repos/}
SubversionDownloadStrategy SubversionDownloadStrategy
when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
MercurialDownloadStrategy MercurialDownloadStrategy

View File

@ -9,7 +9,9 @@ class SystemConfig
java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast", err: :close) java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast", err: :close)
return "N/A" unless $CHILD_STATUS.success? return "N/A" unless $CHILD_STATUS.success?
javas = [] javas = []
REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item| REXML::XPath.each(
REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string"
) do |item|
javas << item.text javas << item.text
end end
javas.uniq.join(", ") javas.uniq.join(", ")

View File

@ -1073,7 +1073,8 @@ class Formula
# file doesn't belong to any keg. # file doesn't belong to any keg.
else else
tab_tap = Tab.for_keg(keg).tap tab_tap = Tab.for_keg(keg).tap
return false if tab_tap.nil? # this keg doesn't below to any core/tap formula, most likely coming from a DIY install. # this keg doesn't below to any core/tap formula, most likely coming from a DIY install.
return false if tab_tap.nil?
begin begin
Formulary.factory(keg.name) Formulary.factory(keg.name)
rescue FormulaUnavailableError # rubocop:disable Lint/HandleExceptions rescue FormulaUnavailableError # rubocop:disable Lint/HandleExceptions

View File

@ -186,7 +186,8 @@ class FormulaInstaller
return if pinned_unsatisfied_deps.empty? return if pinned_unsatisfied_deps.empty?
raise CannotInstallFormulaError, raise CannotInstallFormulaError,
"You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing #{formula.full_name} requires the latest version of pinned dependencies" "You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing " \
"#{formula.full_name} requires the latest version of pinned dependencies"
end end
def build_bottle_preinstall def build_bottle_preinstall
@ -527,8 +528,9 @@ class FormulaInstaller
if deps.empty? && only_deps? if deps.empty? && only_deps?
puts "All dependencies for #{formula.full_name} are satisfied." puts "All dependencies for #{formula.full_name} are satisfied."
elsif !deps.empty? elsif !deps.empty?
oh1 "Installing dependencies for #{formula.full_name}: #{deps.map(&:first).map(&Formatter.method(:identifier)).join(", ")}", oh1 "Installing dependencies for #{formula.full_name}: " \
truncate: false "#{deps.map(&:first).map(&Formatter.method(:identifier)).join(", ")}",
truncate: false
deps.each { |dep, options| install_dependency(dep, options) } deps.each { |dep, options| install_dependency(dep, options) }
end end

View File

@ -38,8 +38,11 @@ RUBY_PATH = Pathname.new(RbConfig.ruby)
RUBY_BIN = RUBY_PATH.dirname RUBY_BIN = RUBY_PATH.dirname
HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"]
HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze HOMEBREW_USER_AGENT_RUBY =
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".freeze "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze
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".freeze
# Bintray fallback is here for people auto-updating from a version where # Bintray fallback is here for people auto-updating from a version where
# HOMEBREW_BOTTLE_DEFAULT_DOMAIN isn't set. # HOMEBREW_BOTTLE_DEFAULT_DOMAIN isn't set.

View File

@ -66,7 +66,9 @@ class Keg
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$} INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks].freeze TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks].freeze
ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze
PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share opt Frameworks LinkedKegs var/homebrew/linked].map do |dir| PRUNEABLE_DIRECTORIES = %w[
bin etc include lib sbin share opt Frameworks LinkedKegs var/homebrew/linked
].map do |dir|
case dir case dir
when "LinkedKegs" when "LinkedKegs"
HOMEBREW_LIBRARY/dir HOMEBREW_LIBRARY/dir

View File

@ -1,2 +1,6 @@
PYTHON_VIRTUALENV_URL = "https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz".freeze PYTHON_VIRTUALENV_URL =
PYTHON_VIRTUALENV_SHA256 = "ca07b4c0b54e14a91af9f34d0919790b016923d157afda5efdde55c96718f752".freeze "https://files.pythonhosted.org/packages/33/bc" \
"/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012" \
"/virtualenv-16.0.0.tar.gz".freeze
PYTHON_VIRTUALENV_SHA256 =
"ca07b4c0b54e14a91af9f34d0919790b016923d157afda5efdde55c96718f752".freeze

View File

@ -136,7 +136,9 @@ module Homebrew
end end
end end
log_command = "git log --since='1 month ago' --diff-filter=D --name-only --max-count=1 --format=%H\\\\n%h\\\\n%B -- #{relative_path}" log_command = "git log --since='1 month ago' --diff-filter=D " \
"--name-only --max-count=1 " \
"--format=%H\\\\n%h\\\\n%B -- #{relative_path}"
hash, short_hash, *commit_message, relative_path = hash, short_hash, *commit_message, relative_path =
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp) Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)

View File

@ -211,7 +211,8 @@ module OS
EXECUTABLE_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze EXECUTABLE_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze
MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete
PKG_PATH = "/Library/Developer/CommandLineTools".freeze PKG_PATH = "/Library/Developer/CommandLineTools".freeze
HEADER_PKG_PATH = "/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_:macos_version.pkg".freeze HEADER_PKG_PATH =
"/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_:macos_version.pkg".freeze
HEADER_PKG_ID = "com.apple.pkg.macOS_SDK_headers_for_macOS_10.14".freeze HEADER_PKG_ID = "com.apple.pkg.macOS_SDK_headers_for_macOS_10.14".freeze
# Returns true even if outdated tools are installed, e.g. # Returns true even if outdated tools are installed, e.g.

View File

@ -40,7 +40,8 @@ class X11Requirement < Requirement
end end
def message def message
"X11 is required to install this formula, either Xorg #{min_version} or xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}" "X11 is required to install this formula, either Xorg #{min_version} or " \
"xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}"
end end
def <=>(other) def <=>(other)

View File

@ -46,9 +46,16 @@ module RuboCop
lambda do |corrector| lambda do |corrector|
case node.type case node.type
when :str, :dstr when :str, :dstr
corrector.replace(node.source_range, node.source.to_s.sub(%r{(/usr/local/(s?bin))}, '#{\2}')) corrector.replace(node.source_range,
node.source.to_s.sub(%r{(/usr/local/(s?bin))},
'#{\2}'))
when :int when :int
corrector.remove(range_with_surrounding_comma(range_with_surrounding_space(range: node.source_range, side: :left))) corrector.remove(
range_with_surrounding_comma(
range_with_surrounding_space(range: node.source_range,
side: :left),
),
)
end end
end end
end end

View File

@ -71,7 +71,9 @@ module RuboCop
# Method to format message for reporting component precedence violations # Method to format message for reporting component precedence violations
def component_problem(c1, c2) def component_problem(c1, c2)
return if WHITELIST.include?(@formula_name) return if WHITELIST.include?(@formula_name)
problem "`#{format_component(c1)}` (line #{line_number(c1)}) should be put before `#{format_component(c2)}` (line #{line_number(c2)})" problem "`#{format_component(c1)}` (line #{line_number(c1)}) " \
"should be put before `#{format_component(c2)}` " \
"(line #{line_number(c2)})"
end end
# autocorrect method gets called just after component_problem method call # autocorrect method gets called just after component_problem method call

View File

@ -142,7 +142,9 @@ module RuboCop
def component_problem(c1, c2) def component_problem(c1, c2)
offending_node(c1) offending_node(c1)
problem "dependency \"#{dependency_name(c1)}\" (line #{line_number(c1)}) should be put before dependency \"#{dependency_name(c2)}\" (line #{line_number(c2)})" problem "dependency \"#{dependency_name(c1)}\" " \
"(line #{line_number(c1)}) should be put before dependency "\
"\"#{dependency_name(c2)}\" (line #{line_number(c2)})"
end end
# Reorder two nodes in the source, using the corrector instance in autocorrect method # Reorder two nodes in the source, using the corrector instance in autocorrect method

View File

@ -58,7 +58,9 @@ module RuboCop
# There's an auto-redirect here, but this mistake is incredibly common too. # There's an auto-redirect here, but this mistake is incredibly common too.
# Only applies to the homepage and subdomains for now, not the FTP URLs. # Only applies to the homepage and subdomains for now, not the FTP URLs.
when %r{^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org} when %r{^http://((?:build|cloud|developer|download|extensions|git|
glade|help|library|live|nagios|news|people|
projects|rt|static|wiki|www)\.)?gnome\.org}x
problem "Please use https:// for #{homepage}" problem "Please use https:// for #{homepage}"
# Compact the above into this list as we're able to remove detailed notations, etc over time. # Compact the above into this list as we're able to remove detailed notations, etc over time.

View File

@ -27,7 +27,8 @@ module RuboCop
begin_pos = start_column(parent_class_node) begin_pos = start_column(parent_class_node)
end_pos = end_column(class_node) end_pos = end_column(class_node)
return unless begin_pos-end_pos != 3 return unless begin_pos-end_pos != 3
problem "Use a space in class inheritance: class #{@formula_name.capitalize} < #{class_name(parent_class_node)}" problem "Use a space in class inheritance: " \
"class #{@formula_name.capitalize} < #{class_name(parent_class_node)}"
end end
end end
@ -112,7 +113,8 @@ module RuboCop
find_instance_method_call(body_node, :build, :without?) do |method| find_instance_method_call(body_node, :build, :without?) do |method|
arg = parameters(method).first arg = parameters(method).first
next unless match = regex_match_group(arg, /^-?-?without-(.*)/) next unless match = regex_match_group(arg, /^-?-?without-(.*)/)
problem "Don't duplicate 'without': Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\"" problem "Don't duplicate 'without': " \
"Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\""
end end
find_instance_method_call(body_node, :build, :with?) do |method| find_instance_method_call(body_node, :build, :with?) do |method|
@ -124,7 +126,8 @@ module RuboCop
find_instance_method_call(body_node, :build, :include?) do |method| find_instance_method_call(body_node, :build, :include?) do |method|
arg = parameters(method).first arg = parameters(method).first
next unless match = regex_match_group(arg, /^with(out)?-(.*)/) next unless match = regex_match_group(arg, /^with(out)?-(.*)/)
problem "Use build.with#{match[1]}? \"#{match[2]}\" instead of build.include? 'with#{match[1]}-#{match[2]}'" problem "Use build.with#{match[1]}? \"#{match[2]}\" instead of " \
"build.include? 'with#{match[1]}-#{match[2]}'"
end end
find_instance_method_call(body_node, :build, :include?) do |method| find_instance_method_call(body_node, :build, :include?) do |method|
@ -345,7 +348,11 @@ module RuboCop
problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\"" problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\""
end end
fileutils_methods = Regexp.new(FileUtils.singleton_methods(false).map { |m| "(?-mix:^" + Regexp.escape(m) + "$)" }.join("|")) fileutils_methods = Regexp.new(
FileUtils.singleton_methods(false)
.map { |m| "(?-mix:^" + Regexp.escape(m) + "$)" }
.join("|"),
)
find_every_method_call_by_name(body_node, :system).each do |method| find_every_method_call_by_name(body_node, :system).each do |method|
param = parameters(method).first param = parameters(method).first
next unless match = regex_match_group(param, fileutils_methods) next unless match = regex_match_group(param, fileutils_methods)

View File

@ -48,7 +48,8 @@ module RuboCop
end end
end end
gh_patch_diff_pattern = %r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)} gh_patch_diff_pattern =
%r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)}
if match_obj = regex_match_group(patch, gh_patch_diff_pattern) if match_obj = regex_match_group(patch, gh_patch_diff_pattern)
problem <<~EOS problem <<~EOS
use GitHub pull request URLs: use GitHub pull request URLs:

View File

@ -92,7 +92,9 @@ module Homebrew
system(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", *args) system(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", *args)
!$CHILD_STATUS.success? !$CHILD_STATUS.success?
when :json when :json
json, err, status = Open3.capture3(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", "--format", "json", *args) json, err, status =
Open3.capture3(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_",
"--format", "json", *args)
# exit status of 1 just means violations were found; other numbers mean # exit status of 1 just means violations were found; other numbers mean
# execution errors. # execution errors.
# exitstatus can also be nil if RuboCop process crashes, e.g. due to # exitstatus can also be nil if RuboCop process crashes, e.g. due to
@ -148,7 +150,8 @@ module Homebrew
def to_s(options = {}) def to_s(options = {})
if options[:display_cop_name] if options[:display_cop_name]
"#{severity_code}: #{location.to_short_s}: #{cop_name}: #{Tty.green}#{correction_status}#{Tty.reset}#{message}" "#{severity_code}: #{location.to_short_s}: #{cop_name}: " \
"#{Tty.green}#{correction_status}#{Tty.reset}#{message}"
else else
"#{severity_code}: #{location.to_short_s}: #{Tty.green}#{correction_status}#{Tty.reset}#{message}" "#{severity_code}: #{location.to_short_s}: #{Tty.green}#{correction_status}#{Tty.reset}#{message}"
end end

View File

@ -26,7 +26,9 @@ describe "Accessibility Access", :cask do
it "warns about disabling accessibility access on old macOS releases" do it "warns about disabling accessibility access on old macOS releases" do
expect { expect {
installer.disable_accessibility_access installer.disable_accessibility_access
}.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr }.to output(
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
).to_stderr
end end
end end
@ -36,7 +38,10 @@ describe "Accessibility Access", :cask do
it "can enable accessibility access" do it "can enable accessibility access" do
expect(fake_system_command).to receive(:run!).with( expect(fake_system_command).to receive(:run!).with(
"/usr/bin/sqlite3", "/usr/bin/sqlite3",
args: [MacOS.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"], args: [
MacOS.tcc_db,
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);",
],
sudo: true, sudo: true,
) )
@ -62,13 +67,17 @@ describe "Accessibility Access", :cask do
expect { expect {
installer.enable_accessibility_access installer.enable_accessibility_access
}.to output.to_stdout }.to output.to_stdout
}.to output(/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./).to_stderr }.to output(
/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./,
).to_stderr
end end
it "warns about disabling accessibility access on new macOS releases" do it "warns about disabling accessibility access on new macOS releases" do
expect { expect {
installer.disable_accessibility_access installer.disable_accessibility_access
}.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr }.to output(
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
).to_stderr
end end
end end
end end

View File

@ -63,7 +63,10 @@ describe Hbc::Artifact::App, :cask do
end end
it "avoids clobbering an existing app" do it "avoids clobbering an existing app" do
expect { install_phase }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") expect { install_phase }.to raise_error(
Hbc::CaskError,
"It seems there is already an App at '#{target_path}'.",
)
expect(source_path).to be_a_directory expect(source_path).to be_a_directory
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
@ -110,12 +113,21 @@ describe Hbc::Artifact::App, :cask do
end end
it "overwrites the existing app" do it "overwrites the existing app" do
expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "--", "u+rwx", target_path], must_succeed: false) expect(command).to receive(:run).with(
.and_call_original "/bin/chmod", args: [
expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "-N", target_path], must_succeed: false) "-R", "--", "u+rwx", target_path
.and_call_original ], must_succeed: false
expect(command).to receive(:run).with("/usr/bin/chflags", args: ["-R", "--", "000", target_path], must_succeed: false) ).and_call_original
.and_call_original expect(command).to receive(:run).with(
"/bin/chmod", args: [
"-R", "-N", target_path
], must_succeed: false
).and_call_original
expect(command).to receive(:run).with(
"/usr/bin/chflags", args: [
"-R", "--", "000", target_path
], must_succeed: false
).and_call_original
stdout = <<~EOS stdout = <<~EOS
==> Removing App '#{target_path}'. ==> Removing App '#{target_path}'.
@ -154,7 +166,9 @@ describe Hbc::Artifact::App, :cask do
end end
it "leaves the target alone" do it "leaves the target alone" do
expect { install_phase }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") expect { install_phase }.to raise_error(
Hbc::CaskError, "It seems there is already an App at '#{target_path}'."
)
expect(target_path).to be_a_symlink expect(target_path).to be_a_symlink
end end

View File

@ -57,7 +57,11 @@ describe Hbc::Artifact::Pkg, :cask do
expect(fake_system_command).to receive(:run!).with( expect(fake_system_command).to receive(:run!).with(
"/usr/sbin/installer", "/usr/sbin/installer",
args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", cask.staged_path.join("/tmp/choices.xml")], args: [
"-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"),
"-target", "/", "-applyChoiceChangesXML",
cask.staged_path.join("/tmp/choices.xml")
],
sudo: true, sudo: true,
print_stdout: true, print_stdout: true,
env: { env: {

View File

@ -130,7 +130,8 @@ describe Hbc::Cask, :cask do
shared_examples ":latest cask" do |greedy, tap_version, expectations| shared_examples ":latest cask" do |greedy, tap_version, expectations|
expectations.each do |installed_version, expected_output| expectations.each do |installed_version, expected_output|
context "when versions #{installed_version} are installed and the tap version is #{tap_version}, #{greedy ? "" : "not"} greedy" do context "when versions #{installed_version} are installed and the " \
"tap version is #{tap_version}, #{"not" unless greedy} greedy" do
subject { cask.outdated_versions greedy } subject { cask.outdated_versions greedy }
it { it {

View File

@ -68,12 +68,20 @@ describe Hbc::CLI::Install, :cask do
it "returns a suggestion for a misspelled Cask" do it "returns a suggestion for a misspelled Cask" do
expect { expect {
described_class.run("localcaffeine") described_class.run("localcaffeine")
}.to raise_error(Hbc::CaskUnavailableError, /Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean “local-caffeine”?/) }.to raise_error(
Hbc::CaskUnavailableError,
"Cask 'localcaffeine' is unavailable: No Cask with this name exists. "\
"Did you mean “local-caffeine”?",
)
end end
it "returns multiple suggestions for a Cask fragment" do it "returns multiple suggestions for a Cask fragment" do
expect { expect {
described_class.run("local") described_class.run("local")
}.to raise_error(Hbc::CaskUnavailableError, /Cask 'local' is unavailable: No Cask with this name exists\. Did you mean one of these\?\nlocal-caffeine\nlocal-transmission/) }.to raise_error(
Hbc::CaskUnavailableError,
"Cask 'local' is unavailable: No Cask with this name exists. " \
"Did you mean one of these?\nlocal-caffeine\nlocal-transmission\n",
)
end end
end end

View File

@ -61,7 +61,10 @@ describe Hbc::CLI::Style, :cask do
end end
specify "`rubocop-cask` supports `HOMEBREW_RUBOCOP_VERSION`", :needs_network do specify "`rubocop-cask` supports `HOMEBREW_RUBOCOP_VERSION`", :needs_network do
stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote") stdout, status = Open3.capture2(
"gem", "dependency", "rubocop-cask",
"--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote"
)
expect(status).to be_a_success expect(status).to be_a_success
@ -89,7 +92,10 @@ describe Hbc::CLI::Style, :cask do
end end
end end
it { is_expected.to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask/Casks"), a_path_ending_with("/third-party/homebrew-tap/Casks")) } it {
is_expected.to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask/Casks"),
a_path_ending_with("/third-party/homebrew-tap/Casks"))
}
end end
context "when at least one cask token is a path that exists" do context "when at least one cask token is a path that exists" do

View File

@ -144,7 +144,9 @@ describe Hbc::CLI::Uninstall, :cask do
describe "when Casks in Taps have been renamed or removed" do describe "when Casks in Taps have been renamed or removed" do
let(:app) { Hbc::Config.global.appdir.join("ive-been-renamed.app") } let(:app) { Hbc::Config.global.appdir.join("ive-been-renamed.app") }
let(:caskroom_path) { Hbc::Caskroom.path.join("ive-been-renamed").tap(&:mkpath) } let(:caskroom_path) { Hbc::Caskroom.path.join("ive-been-renamed").tap(&:mkpath) }
let(:saved_caskfile) { caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb") } let(:saved_caskfile) {
caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb")
}
before do before do
app.tap(&:mkpath) app.tap(&:mkpath)

View File

@ -27,28 +27,4 @@ describe Hbc::CLI::Zap, :cask do
expect(transmission).not_to be_installed expect(transmission).not_to be_installed
expect(Hbc::Config.global.appdir.join("Transmission.app")).not_to be_a_symlink expect(Hbc::Config.global.appdir.join("Transmission.app")).not_to be_a_symlink
end end
# TODO: Explicit test that both zap and uninstall directives get dispatched.
# The above tests that implicitly.
#
# it "dispatches both uninstall and zap stanzas" do
# with_zap = Hbc::CaskLoader.load('with-zap')
#
# Hbc::Installer.new(with_zap).install
#
# with_zap.must_be :installed?
#
# FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
# FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])
# FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1')
# FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit'])
#
# FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
# FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
#
# Hbc::CLI::Zap.run('with-zap')
#
# with_zap.wont_be :installed?
# end
end end

View File

@ -12,8 +12,11 @@ describe "Satisfy Dependencies and Requirements", :cask do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) } let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
it { it {
is_expected.to raise_error(Hbc::CaskCyclicDependencyError, is_expected.to raise_error(
"Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies on other Casks: with-depends-on-cask-cyclic-helper") Hbc::CaskCyclicDependencyError,
"Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies "\
"on other Casks: with-depends-on-cask-cyclic-helper",
)
} }
end end

View File

@ -110,7 +110,19 @@ describe Hbc::Installer, :cask do
expect { expect {
Hbc::Installer.new(with_installer_manual).install Hbc::Installer.new(with_installer_manual).install
}.to output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/).to_stdout }.to output(
<<~EOS
==> Satisfying dependencies
==> Downloading file:#{HOMEBREW_LIBRARY_PATH}/test/support/fixtures/cask/caffeine.zip
==> Verifying checksum for Cask with-installer-manual
==> Installing Cask with-installer-manual
To complete the installation of Cask with-installer-manual, you must also
run the installer at
'#{with_installer_manual.staged_path.join("Caffeine.app")}'
🍺 with-installer-manual was successfully installed!
EOS
).to_stdout
expect(with_installer_manual).to be_installed expect(with_installer_manual).to be_installed
end end
@ -227,7 +239,8 @@ describe Hbc::Installer, :cask do
expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory
expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).not_to be_a_directory expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).not_to be_a_directory
FileUtils.mv(Hbc::Caskroom.path.join("local-caffeine", caffeine.version), Hbc::Caskroom.path.join("local-caffeine", mutated_version)) FileUtils.mv(Hbc::Caskroom.path.join("local-caffeine", caffeine.version),
Hbc::Caskroom.path.join("local-caffeine", mutated_version))
expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).not_to be_a_directory expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).not_to be_a_directory
expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).to be_a_directory expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).to be_a_directory

View File

@ -57,7 +57,9 @@ describe Hbc::Pkg, :cask do
it "removes broken symlinks" do it "removes broken symlinks" do
fake_root = mktmpdir fake_root = mktmpdir
fake_dir = mktmpdir fake_dir = mktmpdir
fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } fake_file = fake_dir.join("ima_file").tap do |path|
FileUtils.touch(path)
end
intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) }
broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") } broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") }

View File

@ -234,13 +234,21 @@ describe CurlDownloadStrategy do
subject { described_class.new(url, name, version, **specs).cached_location } subject { described_class.new(url, name, version, **specs).cached_location }
context "when URL ends with file" do context "when URL ends with file" do
it { is_expected.to eq(HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz") } it {
is_expected.to eq(
HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz",
)
}
end end
context "when URL file is in middle" do context "when URL file is in middle" do
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" } let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }
it { is_expected.to eq(HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz") } it {
is_expected.to eq(
HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz",
)
}
end end
end end
@ -282,7 +290,12 @@ describe CurlDownloadStrategy do
it "adds the appropriate curl args" do it "adds the appropriate curl args" do
expect(subject).to receive(:system_command!) { |*, args:, **| expect(subject).to receive(:system_command!) { |*, args:, **|
expect(args.each_cons(2).to_a).to include(["--user-agent", a_string_matching(/Mozilla.*Mac OS X 10.*AppleWebKit/)]) expect(args.each_cons(2).to_a).to include(
[
"--user-agent",
a_string_matching(/Mozilla.*Mac OS X 10.*AppleWebKit/),
],
)
} }
subject.fetch subject.fetch
@ -505,8 +518,8 @@ describe SubversionDownloadStrategy do
it "adds the appropriate svn args" do it "adds the appropriate svn args" do
expect(subject).to receive(:system_command!) expect(subject).to receive(:system_command!)
.with("svn", args: array_including("--trust-server-cert", "--non-interactive")) .with("svn", args: array_including("--trust-server-cert",
"--non-interactive"))
subject.fetch subject.fetch
end end
end end

View File

@ -19,15 +19,18 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz", "url" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz",
"msg" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz should be `https://cpan.metacpan.org/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz`", "msg" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz should be " \
"`https://cpan.metacpan.org/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz`",
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg", "url" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg",
"msg" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg should be `https://download.gnome.org/binaries/mac/banshee/banshee-2.macosx.intel.dmg`", "msg" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg should be " \
"`https://download.gnome.org/binaries/mac/banshee/banshee-2.macosx.intel.dmg`",
"col" => 2, "col" => 2,
}, { }, {
"url" => "git://anonscm.debian.org/users/foo/foostrap.git", "url" => "git://anonscm.debian.org/users/foo/foostrap.git",
"msg" => "git://anonscm.debian.org/users/foo/foostrap.git should be `https://anonscm.debian.org/git/users/foo/foostrap.git`", "msg" => "git://anonscm.debian.org/users/foo/foostrap.git should be " \
"`https://anonscm.debian.org/git/users/foo/foostrap.git`",
"col" => 2, "col" => 2,
}, { }, {
"url" => "ftp://ftp.mirrorservice.org/foo-1.tar.gz", "url" => "ftp://ftp.mirrorservice.org/foo-1.tar.gz",
@ -39,15 +42,18 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://sourceforge.net/projects/something/files/Something-1.2.3.dmg", "url" => "http://sourceforge.net/projects/something/files/Something-1.2.3.dmg",
"msg" => "Use https://downloads.sourceforge.net to get geolocation (url is http://sourceforge.net/projects/something/files/Something-1.2.3.dmg).", "msg" => "Use https://downloads.sourceforge.net to get geolocation (url is " \
"http://sourceforge.net/projects/something/files/Something-1.2.3.dmg).",
"col" => 2, "col" => 2,
}, { }, {
"url" => "https://downloads.sourceforge.net/project/foo/download", "url" => "https://downloads.sourceforge.net/project/foo/download",
"msg" => "Don't use /download in SourceForge urls (url is https://downloads.sourceforge.net/project/foo/download).", "msg" => "Don't use /download in SourceForge urls (url is " \
"https://downloads.sourceforge.net/project/foo/download).",
"col" => 2, "col" => 2,
}, { }, {
"url" => "https://sourceforge.net/project/foo", "url" => "https://sourceforge.net/project/foo",
"msg" => "Use https://downloads.sourceforge.net to get geolocation (url is https://sourceforge.net/project/foo).", "msg" => "Use https://downloads.sourceforge.net to get geolocation " \
"(url is https://sourceforge.net/project/foo).",
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://prdownloads.sourceforge.net/foo/foo-1.tar.gz", "url" => "http://prdownloads.sourceforge.net/foo/foo-1.tar.gz",
@ -58,7 +64,8 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2", "url" => "http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2",
"msg" => "Don't use specific dl mirrors in SourceForge urls (url is http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2).", "msg" => "Don't use specific dl mirrors in SourceForge urls (url is " \
"http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2).",
"col" => 2, "col" => 2,
}, { }, {
"url" => "http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip", "url" => "http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip",
@ -107,7 +114,8 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"col" => 2, "col" => 2,
}, { }, {
"url" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar", "url" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar",
"msg" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar should be `https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`", "msg" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar should be " \
"`https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`",
"col" => 2, "col" => 2,
}] }]
formulas.each do |formula| formulas.each do |formula|

View File

@ -223,9 +223,15 @@ describe SystemCommand do
it 'does not format `stderr` when it starts with \r' do it 'does not format `stderr` when it starts with \r' do
expect { expect {
system_command "bash", system_command \
args: ["-c", 'printf "\r%s" "################### 27.6%" 1>&2'] "bash",
}.to output("\r################### 27.6%").to_stderr args: [
"-c",
'printf "\r%s" "################### 27.6%" 1>&2',
]
}.to output( \
"\r################### 27.6%",
).to_stderr
end end
context "when given an executable with spaces and no arguments" do context "when given an executable with spaces and no arguments" do

View File

@ -243,7 +243,10 @@ describe Tab do
end end
it "raises a parse exception message including the Tab filename" do it "raises a parse exception message including the Tab filename" do
expect { described_class.from_file_content("''", "receipt.json") }.to raise_error(JSON::ParserError, /receipt.json:/) expect { described_class.from_file_content("''", "receipt.json") }.to raise_error(
JSON::ParserError,
/receipt.json:/,
)
end end
end end

View File

@ -214,7 +214,9 @@ describe Tap do
touch subject.path/".git/shallow" touch subject.path/".git/shallow"
expect(already_tapped_tap).to be_installed expect(already_tapped_tap).to be_installed
wrong_remote = "#{subject.remote}-oops" wrong_remote = "#{subject.remote}-oops"
expect { already_tapped_tap.install clone_target: wrong_remote, full_clone: true }.to raise_error(TapRemoteMismatchError) expect {
already_tapped_tap.install clone_target: wrong_remote, full_clone: true
}.to raise_error(TapRemoteMismatchError)
end end
it "raises an error when the Tap is already unshallow" do it "raises an error when the Tap is already unshallow" do

View File

@ -54,7 +54,9 @@ describe UpdateMigrator do
} }
let(:old_cache_file) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" } let(:old_cache_file) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
let(:new_cache_symlink) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" } let(:new_cache_symlink) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
let(:new_cache_file) { HOMEBREW_CACHE/"downloads/5994e3a27baa3f448a001fb071ab1f0bf25c87aebcb254d91a6d0b02f46eef86--foo-1.2.3.tar.gz" } let(:new_cache_file) {
HOMEBREW_CACHE/"downloads/5994e3a27baa3f448a001fb071ab1f0bf25c87aebcb254d91a6d0b02f46eef86--foo-1.2.3.tar.gz"
}
before(:each) do before(:each) do
old_cache_file.dirname.mkpath old_cache_file.dirname.mkpath

View File

@ -261,7 +261,10 @@ describe "globally-scoped helper methods" do
caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"],
disable: true disable: true
) )
}.to raise_error(MethodDeprecatedError, %r{method.*replacement.*homebrew/core.*\/Taps\/homebrew\/homebrew-core\/}m) }.to raise_error(
MethodDeprecatedError,
%r{method.*replacement.*homebrew/core.*\/Taps\/homebrew\/homebrew-core\/}m,
)
end end
end end

View File

@ -312,7 +312,10 @@ describe Version do
specify "elasticsearch alpha style" do specify "elasticsearch alpha style" do
expect(described_class.create("5.0.0-alpha5")) expect(described_class.create("5.0.0-alpha5"))
.to be_detected_from("https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha5/elasticsearch-5.0.0-alpha5.tar.gz") .to be_detected_from(
"https://download.elastic.co/elasticsearch/release/org/elasticsearch" \
"/distribution/tar/elasticsearch/5.0.0-alpha5/elasticsearch-5.0.0-alpha5.tar.gz",
)
end end
specify "gloox beta style" do specify "gloox beta style" do
@ -480,7 +483,9 @@ describe Version do
expect(described_class.create("2.074.0-rc1")) expect(described_class.create("2.074.0-rc1"))
.to be_detected_from("https://github.com/dlang/dmd/archive/v2.074.0-rc1.tar.gz") .to be_detected_from("https://github.com/dlang/dmd/archive/v2.074.0-rc1.tar.gz")
expect(described_class.create("5.0.0-alpha10")) expect(described_class.create("5.0.0-alpha10"))
.to be_detected_from("https://github.com/premake/premake-core/releases/download/v5.0.0-alpha10/premake-5.0.0-alpha10-src.zip") .to be_detected_from(
"https://github.com/premake/premake-core/releases/download/v5.0.0-alpha10/premake-5.0.0-alpha10-src.zip",
)
end end
specify "jenkins version style" do specify "jenkins version style" do
@ -512,14 +517,21 @@ describe Version do
expect(described_class.create("9.2")) expect(described_class.create("9.2"))
.to be_detected_from("https://cdn.nuxeo.com/nuxeo-9.2/nuxeo-server-9.2-tomcat.zip") .to be_detected_from("https://cdn.nuxeo.com/nuxeo-9.2/nuxeo-server-9.2-tomcat.zip")
expect(described_class.create("0.181")) expect(described_class.create("0.181"))
.to be_detected_from("https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-cli/0.181/presto-cli-0.181-executable.jar") .to be_detected_from(
"https://search.maven.org/remotecontent?filepath=" \
"com/facebook/presto/presto-cli/0.181/presto-cli-0.181-executable.jar",
)
expect(described_class.create("1.2.3")) expect(described_class.create("1.2.3"))
.to be_detected_from("https://search.maven.org/remotecontent?filepath=org/apache/orc/orc-tools/1.2.3/orc-tools-1.2.3-uber.jar") .to be_detected_from(
"https://search.maven.org/remotecontent?filepath=org/apache/orc/orc-tools/1.2.3/orc-tools-1.2.3-uber.jar",
)
end end
specify "apache version style" do specify "apache version style" do
expect(described_class.create("1.2.0-rc2")) expect(described_class.create("1.2.0-rc2"))
.to be_detected_from("https://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz") .to be_detected_from(
"https://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz",
)
end end
specify "jpeg version style" do specify "jpeg version style" do
@ -556,7 +568,9 @@ describe Version do
specify "cmucl version style" do specify "cmucl version style" do
expect(described_class.create("20c")) expect(described_class.create("20c"))
.to be_detected_from("https://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2") .to be_detected_from(
"https://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2",
)
end end
specify "fann version style" do specify "fann version style" do
@ -581,7 +595,9 @@ describe Version do
specify "suite3270 version style" do specify "suite3270 version style" do
expect(described_class.create("3.3.12ga7")) expect(described_class.create("3.3.12ga7"))
.to be_detected_from("https://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz") .to be_detected_from(
"https://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz",
)
end end
specify "wwwoffle version style" do specify "wwwoffle version style" do
@ -596,12 +612,17 @@ describe Version do
specify "fontforge version style" do specify "fontforge version style" do
expect(described_class.create("20120731")) expect(described_class.create("20120731"))
.to be_detected_from("https://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2") .to be_detected_from(
"https://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2",
)
end end
specify "ezlupdate version style" do specify "ezlupdate version style" do
expect(described_class.create("2011.10")) expect(described_class.create("2011.10"))
.to be_detected_from("https://github.com/downloads/ezsystems/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2") .to be_detected_from(
"https://github.com/downloads/ezsystems" \
"/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2",
)
end end
specify "aespipe version style" do specify "aespipe version style" do

View File

@ -124,11 +124,16 @@ module UnpackStrategy
Dir.mktmpdir do |mount_dir| Dir.mktmpdir do |mount_dir|
mount_dir = Pathname(mount_dir) mount_dir = Pathname(mount_dir)
without_eula = system_command "hdiutil", without_eula = system_command(
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, path], "hdiutil",
input: "qn\n", args: [
print_stderr: false, "attach", "-plist", "-nobrowse", "-readonly", "-noidme",
verbose: verbose "-mountrandom", mount_dir, path
],
input: "qn\n",
print_stderr: false,
verbose: verbose,
)
# If mounting without agreeing to EULA succeeded, there is none. # If mounting without agreeing to EULA succeeded, there is none.
plist = if without_eula.success? plist = if without_eula.success?
@ -136,13 +141,22 @@ module UnpackStrategy
else else
cdr_path = mount_dir/path.basename.sub_ext(".cdr") cdr_path = mount_dir/path.basename.sub_ext(".cdr")
system_command! "hdiutil", system_command!(
args: ["convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path], "hdiutil",
verbose: verbose args: [
"convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path
],
verbose: verbose,
)
with_eula = system_command! "hdiutil", with_eula = system_command!(
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, cdr_path], "hdiutil",
verbose: verbose args: [
"attach", "-plist", "-nobrowse", "-readonly", "-noidme",
"-mountrandom", mount_dir, cdr_path
],
verbose: verbose,
)
if verbose && !(eula_text = without_eula.stdout).empty? if verbose && !(eula_text = without_eula.stdout).empty?
ohai "Software License Agreement for '#{path}':" ohai "Software License Agreement for '#{path}':"

View File

@ -20,7 +20,10 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:) def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "unar", system_command! "unar",
args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", path], args: [
"-force-overwrite", "-quiet", "-no-directory",
"-output-directory", unpack_dir, "--", path
],
env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) }, env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) },
verbose: verbose verbose: verbose
end end

View File

@ -9,7 +9,9 @@ module GitHub
CREATE_GIST_SCOPES = ["gist"].freeze CREATE_GIST_SCOPES = ["gist"].freeze
CREATE_ISSUE_FORK_OR_PR_SCOPES = ["public_repo"].freeze CREATE_ISSUE_FORK_OR_PR_SCOPES = ["public_repo"].freeze
ALL_SCOPES = (CREATE_GIST_SCOPES + CREATE_ISSUE_FORK_OR_PR_SCOPES).freeze ALL_SCOPES = (CREATE_GIST_SCOPES + CREATE_ISSUE_FORK_OR_PR_SCOPES).freeze
ALL_SCOPES_URL = Formatter.url("https://github.com/settings/tokens/new?scopes=#{ALL_SCOPES.join(",")}&description=Homebrew").freeze ALL_SCOPES_URL = Formatter.url(
"https://github.com/settings/tokens/new?scopes=#{ALL_SCOPES.join(",")}&description=Homebrew",
).freeze
PR_ENV_KEY = "HOMEBREW_NEW_FORMULA_PULL_REQUEST_URL".freeze PR_ENV_KEY = "HOMEBREW_NEW_FORMULA_PULL_REQUEST_URL".freeze
PR_ENV = ENV[PR_ENV_KEY] PR_ENV = ENV[PR_ENV_KEY]