Merge pull request #15104 from dduugg/enable-io-types
Enable IO and UpdateTest types
This commit is contained in:
commit
0d17bbbec6
@ -1,14 +1,12 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
module Homebrew
|
||||
extend T::Sig
|
||||
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def update_test_args
|
||||
def self.update_test_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Run a test of `brew update` with a new repository clone.
|
||||
@ -27,7 +25,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def update_test
|
||||
def self.update_test
|
||||
args = update_test_args.parse
|
||||
|
||||
# Avoid `update-report.rb` tapping Homebrew/homebrew-core
|
||||
@ -51,10 +49,12 @@ module Homebrew
|
||||
"master"
|
||||
end
|
||||
|
||||
start_commit = nil
|
||||
# Utils.popen_read returns a String without a block argument, but that isn't easily typed. We thus label this
|
||||
# as untyped for now.
|
||||
start_commit = T.let("", T.untyped)
|
||||
end_commit = "HEAD"
|
||||
cd HOMEBREW_REPOSITORY do
|
||||
start_commit = if (commit = args.commit)
|
||||
start_commit = if (commit = T.let(args.commit, T.nilable(String)))
|
||||
commit
|
||||
elsif (date = args.before)
|
||||
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
|
||||
@ -78,7 +78,7 @@ module Homebrew
|
||||
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
|
||||
odie "Could not find start commit!" if start_commit.empty?
|
||||
|
||||
end_commit = Utils.popen_read("git", "rev-parse", end_commit).chomp
|
||||
end_commit = T.cast(Utils.popen_read("git", "rev-parse", end_commit).chomp, String)
|
||||
odie "Could not find end commit!" if end_commit.empty?
|
||||
|
||||
if Utils.popen_read("git", "branch", "--list", "master").blank?
|
||||
@ -114,7 +114,7 @@ module Homebrew
|
||||
safe_system "git", "reset", "--hard", start_commit
|
||||
|
||||
# update ENV["PATH"]
|
||||
ENV["PATH"] = PATH.new(ENV.fetch("PATH")).prepend(curdir/"bin")
|
||||
ENV["PATH"] = PATH.new(ENV.fetch("PATH")).prepend(curdir/"bin").to_s
|
||||
|
||||
# run brew help to install portable-ruby (if needed)
|
||||
quiet_system "brew", "help"
|
||||
@ -139,7 +139,7 @@ module Homebrew
|
||||
FileUtils.rm_rf "update-test" unless args.keep_tmp?
|
||||
end
|
||||
|
||||
def git_tags
|
||||
def self.git_tags
|
||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
if tags.blank?
|
||||
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
|
||||
|
||||
@ -117,6 +117,6 @@ module GitRepositoryExtension
|
||||
raise "Git is unavailable"
|
||||
end
|
||||
|
||||
T.unsafe(Utils).popen_read(Utils::Git.git, *args, safe: safe, chdir: self, err: err).chomp.presence
|
||||
Utils.popen_read(Utils::Git.git, *args, safe: safe, chdir: self, err: err).chomp.presence
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IO
|
||||
@ -6,17 +6,19 @@ class IO
|
||||
line = +""
|
||||
buffer = +""
|
||||
|
||||
loop do
|
||||
break if buffer == sep
|
||||
begin
|
||||
loop do
|
||||
break if buffer == sep
|
||||
|
||||
read_nonblock(1, buffer)
|
||||
line.concat(buffer)
|
||||
read_nonblock(1, buffer)
|
||||
line.concat(buffer)
|
||||
end
|
||||
|
||||
line.freeze
|
||||
rescue IO::WaitReadable, EOFError
|
||||
raise if line.empty?
|
||||
|
||||
line.freeze
|
||||
end
|
||||
|
||||
line.freeze
|
||||
rescue IO::WaitReadable, EOFError => e
|
||||
raise e if line.empty?
|
||||
|
||||
line.freeze
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user