rm popen sigs
This commit is contained in:
parent
a20d28f343
commit
4f5fc770f6
@ -130,7 +130,7 @@ module Homebrew
|
||||
|
||||
new_tag = Utils.popen_read(
|
||||
"git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname", "*.*"
|
||||
).lines.fetch(0).chomp
|
||||
).lines.first.chomp
|
||||
|
||||
Settings.write "latesttag", new_tag if new_tag != old_tag
|
||||
|
||||
@ -286,8 +286,6 @@ module Homebrew
|
||||
puts
|
||||
|
||||
new_major_version, new_minor_version, new_patch_version = new_tag.split(".").map(&:to_i)
|
||||
raise "Invalid new tag: #{new_tag}" if !new_major_version || !new_minor_version || !new_patch_version
|
||||
|
||||
old_major_version, old_minor_version = (old_tag.split(".")[0, 2]).map(&:to_i) if old_tag.present?
|
||||
if old_tag.blank? || new_major_version > old_major_version \
|
||||
|| new_minor_version > old_minor_version
|
||||
|
||||
@ -234,13 +234,13 @@ module Homebrew
|
||||
"--reverse", "#{original_commit}..HEAD").lines.map(&:strip)
|
||||
|
||||
# Generate a bidirectional mapping of commits <=> formula/cask files.
|
||||
files_to_commits = T.let({}, T::Hash[String, T::Array[String]])
|
||||
files_to_commits = {}
|
||||
commits_to_files = commits.to_h do |commit|
|
||||
files = Utils.safe_popen_read("git", "-C", tap.path, "diff-tree", "--diff-filter=AMD",
|
||||
"-r", "--name-only", "#{commit}^", commit).lines.map(&:strip)
|
||||
files.each do |file|
|
||||
files_to_commits[file] ||= []
|
||||
files_to_commits.fetch(file) << commit
|
||||
files_to_commits[file] << commit
|
||||
tap_file = tap.path/file
|
||||
if (tap_file.dirname == tap.formula_dir || tap_file.dirname == tap.cask_dir) &&
|
||||
File.extname(file) == ".rb"
|
||||
@ -266,14 +266,14 @@ module Homebrew
|
||||
next if processed_commits.include? commit
|
||||
|
||||
files = commits_to_files[commit]
|
||||
if files.length == 1 && files_to_commits.fetch(files.first).length == 1
|
||||
if files.length == 1 && files_to_commits[files.first].length == 1
|
||||
# If there's a 1:1 mapping of commits to files, just cherry pick and (maybe) reword.
|
||||
reword_package_commit(commit, files.first, path: tap.path, reason: reason, verbose: verbose, resolve: resolve)
|
||||
processed_commits << commit
|
||||
elsif files.length == 1 && files_to_commits.fetch(files.first).length > 1
|
||||
elsif files.length == 1 && files_to_commits[files.first].length > 1
|
||||
# If multiple commits modify a single file, squash them down into a single commit.
|
||||
file = files.first
|
||||
commits = files_to_commits.fetch(file)
|
||||
commits = files_to_commits[file]
|
||||
squash_package_commits(commits, file, path: tap.path, reason: reason, verbose: verbose, resolve: resolve)
|
||||
processed_commits += commits
|
||||
else
|
||||
@ -336,7 +336,7 @@ module Homebrew
|
||||
rescue FormulaUnavailableError
|
||||
nil
|
||||
end
|
||||
end
|
||||
end.compact
|
||||
casks = Utils.popen_read("git", "-C", tap.path, "diff-tree",
|
||||
"-r", "--name-only", "--diff-filter=AM",
|
||||
original_commit, "HEAD", "--", tap.cask_dir)
|
||||
@ -351,7 +351,7 @@ module Homebrew
|
||||
nil
|
||||
end
|
||||
end.compact
|
||||
T.must(formulae).compact + casks
|
||||
formulae + casks
|
||||
end
|
||||
|
||||
def self.download_artifact(url, dir, pull_request)
|
||||
|
||||
@ -40,11 +40,8 @@ module Superenv
|
||||
paths = []
|
||||
# Add paths for GCC headers when building against glibc@2.13 because we have to use -nostdinc.
|
||||
if deps.any? { |d| d.name == "glibc@2.13" }
|
||||
env_cc = cc
|
||||
raise "No CC compiler found in ENV" if env_cc.nil?
|
||||
|
||||
gcc_include_dir = Utils.safe_popen_read(env_cc, "--print-file-name=include").chomp
|
||||
gcc_include_fixed_dir = Utils.safe_popen_read(env_cc, "--print-file-name=include-fixed").chomp
|
||||
gcc_include_dir = Utils.safe_popen_read(cc, "--print-file-name=include").chomp
|
||||
gcc_include_fixed_dir = Utils.safe_popen_read(cc, "--print-file-name=include-fixed").chomp
|
||||
paths << gcc_include_dir << gcc_include_fixed_dir
|
||||
end
|
||||
paths
|
||||
|
||||
@ -338,7 +338,7 @@ class Keg
|
||||
# Some binaries contain strings with lists of files
|
||||
# e.g. `/usr/local/lib/foo:/usr/local/share/foo:/usr/lib/foo`
|
||||
# Each item in the list should be checked separately
|
||||
T.must(match).split(":").each do |sub_match|
|
||||
match.split(":").each do |sub_match|
|
||||
# Not all items in the list may be matches
|
||||
next unless sub_match.match? path_regex
|
||||
next if linked_libraries.include? sub_match # Don't bother reporting a string if it was found by otool
|
||||
|
||||
@ -34,7 +34,7 @@ module Language
|
||||
output = Utils.popen_read("npm", "pack", "--ignore-scripts")
|
||||
raise "npm failed to pack #{Dir.pwd}" if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
|
||||
|
||||
output.lines.fetch(-1).chomp
|
||||
output.lines.last.chomp
|
||||
end
|
||||
|
||||
def self.setup_npm_environment
|
||||
|
||||
@ -179,7 +179,7 @@ module Homebrew
|
||||
return
|
||||
end
|
||||
|
||||
commit_message = T.must(commit_message).reject(&:empty?).join("\n ")
|
||||
commit_message = commit_message.reject(&:empty?).join("\n ")
|
||||
|
||||
commit_message.sub!(/ \(#(\d+)\)$/, " (#{tap.issues_url}/\\1)")
|
||||
commit_message.gsub!(/(Closes|Fixes) #(\d+)/, "\\1 #{tap.issues_url}/\\2")
|
||||
|
||||
@ -14,7 +14,7 @@ module OS
|
||||
def os_version
|
||||
if which("lsb_release")
|
||||
lsb_info = Utils.popen_read("lsb_release", "-a")
|
||||
description = T.must(lsb_info[/^Description:\s*(.*)$/, 1]).force_encoding("UTF-8")
|
||||
description = lsb_info[/^Description:\s*(.*)$/, 1].force_encoding("UTF-8")
|
||||
codename = lsb_info[/^Codename:\s*(.*)$/, 1]
|
||||
if codename.blank? || (codename == "n/a")
|
||||
description
|
||||
|
||||
@ -131,7 +131,7 @@ module ELFShim
|
||||
return if needed.empty?
|
||||
|
||||
ldd = DevelopmentTools.locate "ldd"
|
||||
ldd_output = Utils.popen_read(T.must(ldd), path.expand_path.to_s).split("\n")
|
||||
ldd_output = Utils.popen_read(ldd, path.expand_path.to_s).split("\n")
|
||||
return unless $CHILD_STATUS.success?
|
||||
|
||||
ldd_paths = ldd_output.map do |line|
|
||||
|
||||
@ -161,8 +161,7 @@ module OS
|
||||
# Xcode.prefix is pretty smart, so let's look inside to find the sdk
|
||||
sdk_prefix = "#{Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs"
|
||||
# Finally query Xcode itself (this is slow, so check it last)
|
||||
sdk_platform_path = Utils.popen_read(T.must(DevelopmentTools.locate("xcrun")),
|
||||
"--show-sdk-platform-path").chomp
|
||||
sdk_platform_path = Utils.popen_read(DevelopmentTools.locate("xcrun"), "--show-sdk-platform-path").chomp
|
||||
sdk_prefix = File.join(sdk_platform_path, "Developer", "SDKs") unless File.directory? sdk_prefix
|
||||
|
||||
sdk_prefix
|
||||
|
||||
@ -1,20 +1,10 @@
|
||||
# typed: strict
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Utils
|
||||
extend T::Sig
|
||||
|
||||
IO_DEFAULT_BUFFER_SIZE = 4096
|
||||
private_constant :IO_DEFAULT_BUFFER_SIZE
|
||||
|
||||
sig {
|
||||
params(
|
||||
args: T.any(Pathname, String, T::Hash[String, String]),
|
||||
safe: T::Boolean,
|
||||
options: T.untyped,
|
||||
block: T.nilable(T.proc.params(io: IO).void),
|
||||
).returns(T.nilable(String))
|
||||
}
|
||||
def self.popen_read(*args, safe: false, **options, &block)
|
||||
output = popen(args, "rb", options, &block)
|
||||
return output if !safe || $CHILD_STATUS.success?
|
||||
@ -22,26 +12,11 @@ module Utils
|
||||
raise ErrorDuringExecution.new(args, status: $CHILD_STATUS, output: [[:stdout, output]])
|
||||
end
|
||||
|
||||
sig {
|
||||
params(
|
||||
args: T.any(Pathname, String, T::Hash[String, String]),
|
||||
options: T.untyped,
|
||||
block: T.nilable(T.proc.params(io: IO).void),
|
||||
).returns(T.nilable(String))
|
||||
}
|
||||
def self.safe_popen_read(*args, **options, &block)
|
||||
popen_read(*args, safe: true, **options, &block)
|
||||
end
|
||||
|
||||
sig {
|
||||
params(
|
||||
args: T.any(Pathname, String, T::Hash[String, String]),
|
||||
safe: T::Boolean,
|
||||
options: T.untyped,
|
||||
_block: T.proc.params(io: IO).void,
|
||||
).returns(T.nilable(String))
|
||||
}
|
||||
def self.popen_write(*args, safe: false, **options, &_block)
|
||||
def self.popen_write(*args, safe: false, **options)
|
||||
output = ""
|
||||
popen(args, "w+b", options) do |pipe|
|
||||
# Before we yield to the block, capture as much output as we can
|
||||
@ -56,7 +31,7 @@ module Utils
|
||||
pipe.wait_readable
|
||||
|
||||
# Capture the rest of the output
|
||||
output += T.must(pipe.read)
|
||||
output += pipe.read
|
||||
output.freeze
|
||||
end
|
||||
return output if !safe || $CHILD_STATUS.success?
|
||||
@ -64,29 +39,14 @@ module Utils
|
||||
raise ErrorDuringExecution.new(args, status: $CHILD_STATUS, output: [[:stdout, output]])
|
||||
end
|
||||
|
||||
sig {
|
||||
params(
|
||||
args: T.any(Pathname, String, T::Hash[String, String]),
|
||||
options: T.untyped,
|
||||
block: T.nilable(T.proc.params(io: IO).void),
|
||||
).returns(T.nilable(String))
|
||||
}
|
||||
def self.safe_popen_write(*args, **options, &block)
|
||||
popen_write(*args, safe: true, **options, &block)
|
||||
end
|
||||
|
||||
sig {
|
||||
params(
|
||||
args: T::Array[T.any(Pathname, String, T::Hash[String, String])],
|
||||
mode: String,
|
||||
options: T::Hash[Symbol, T.untyped],
|
||||
block: T.nilable(T.proc.params(io: IO).void),
|
||||
).returns(T.nilable(String))
|
||||
}
|
||||
def self.popen(args, mode, options = {}, &block)
|
||||
def self.popen(args, mode, options = {})
|
||||
IO.popen("-", mode) do |pipe|
|
||||
if pipe
|
||||
return pipe.read unless block
|
||||
return pipe.read unless block_given?
|
||||
|
||||
yield pipe
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user