mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Enable typing in a few more files
This commit is contained in:
parent
cb5e8298a2
commit
02fd0422aa
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
|
7
Library/Homebrew/cask/metdata.rbi
Normal file
7
Library/Homebrew/cask/metdata.rbi
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
module Cask
|
||||||
|
module Metadata
|
||||||
|
requires_ancestor { Cask }
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,4 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# typed: false
|
|
||||||
|
|
||||||
class URL
|
class URL
|
||||||
include Kernel
|
include Kernel
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "keg"
|
require "keg"
|
||||||
@ -31,7 +31,7 @@ module Homebrew
|
|||||||
|
|
||||||
def self.checks(type, fatal: true)
|
def self.checks(type, fatal: true)
|
||||||
@checks ||= Checks.new
|
@checks ||= Checks.new
|
||||||
failed = false
|
failed = T.let(false, T::Boolean)
|
||||||
@checks.public_send(type).each do |check|
|
@checks.public_send(type).each do |check|
|
||||||
out = @checks.public_send(check)
|
out = @checks.public_send(check)
|
||||||
next if out.nil?
|
next if out.nil?
|
||||||
@ -64,6 +64,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(list: T::Array[String], string: String).returns(String) }
|
||||||
def inject_file_list(list, string)
|
def inject_file_list(list, string)
|
||||||
list.reduce(string.dup) { |acc, elem| acc << " #{elem}\n" }
|
list.reduce(string.dup) { |acc, elem| acc << " #{elem}\n" }
|
||||||
.freeze
|
.freeze
|
||||||
@ -642,10 +643,11 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_git_status
|
def check_git_status
|
||||||
return unless Utils::Git.available?
|
return unless Utils::Git.available?
|
||||||
|
|
||||||
message = nil
|
message = T.let(nil, T.nilable(String))
|
||||||
|
|
||||||
repos = {
|
repos = {
|
||||||
"Homebrew/brew" => HOMEBREW_REPOSITORY,
|
"Homebrew/brew" => HOMEBREW_REPOSITORY,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
5
Library/Homebrew/formula_assertions.rbi
Normal file
5
Library/Homebrew/formula_assertions.rbi
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
module Homebrew::Assertions
|
||||||
|
include Kernel
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Keg
|
class Keg
|
||||||
@ -44,7 +44,7 @@ class Keg
|
|||||||
key.is_a?(String) ? key.length : 999
|
key.is_a?(String) ? key.length : 999
|
||||||
end.reverse
|
end.reverse
|
||||||
|
|
||||||
any_changed = false
|
any_changed = T.let(nil, T.nilable(String))
|
||||||
sorted_keys.each do |key|
|
sorted_keys.each do |key|
|
||||||
changed = text.gsub!(key, replacements[key])
|
changed = text.gsub!(key, replacements[key])
|
||||||
any_changed ||= changed
|
any_changed ||= changed
|
||||||
@ -144,7 +144,7 @@ class Keg
|
|||||||
def replace_text_in_files(relocation, files: nil)
|
def replace_text_in_files(relocation, files: nil)
|
||||||
files ||= text_files | libtool_files
|
files ||= text_files | libtool_files
|
||||||
|
|
||||||
changed_files = []
|
changed_files = T.let([], Array)
|
||||||
files.map(&path.method(:join)).group_by { |f| f.stat.ino }.each_value do |first, *rest|
|
files.map(&path.method(:join)).group_by { |f| f.stat.ino }.each_value do |first, *rest|
|
||||||
s = first.open("rb", &:read)
|
s = first.open("rb", &:read)
|
||||||
|
|
||||||
@ -179,11 +179,11 @@ class Keg
|
|||||||
binary = File.binread file
|
binary = File.binread file
|
||||||
odebug "Replacing build prefix in: #{file}"
|
odebug "Replacing build prefix in: #{file}"
|
||||||
binary_strings = binary.split(/#{NULL_BYTE}/o, -1)
|
binary_strings = binary.split(/#{NULL_BYTE}/o, -1)
|
||||||
match_indices = binary_strings.each_index.select { |i| binary_strings[i].include?(old_prefix) }
|
match_indices = binary_strings.each_index.select { |i| binary_strings.fetch(i).include?(old_prefix) }
|
||||||
|
|
||||||
# Only perform substitution on strings which match prefix regex.
|
# Only perform substitution on strings which match prefix regex.
|
||||||
match_indices.each do |i|
|
match_indices.each do |i|
|
||||||
s = binary_strings[i]
|
s = binary_strings.fetch(i)
|
||||||
binary_strings[i] = s.gsub(old_prefix, new_prefix)
|
binary_strings[i] = s.gsub(old_prefix, new_prefix)
|
||||||
.ljust(s.size, NULL_BYTE)
|
.ljust(s.size, NULL_BYTE)
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Language
|
module Language
|
||||||
|
11
Library/Homebrew/language/python.rbi
Normal file
11
Library/Homebrew/language/python.rbi
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
module Language::Python
|
||||||
|
module Shebang
|
||||||
|
include Kernel
|
||||||
|
end
|
||||||
|
|
||||||
|
module Virtualenv
|
||||||
|
requires_ancestor { Formula }
|
||||||
|
end
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
raise "#{__FILE__} must not be loaded via `require`." if $PROGRAM_NAME != __FILE__
|
raise "#{__FILE__} must not be loaded via `require`." if $PROGRAM_NAME != __FILE__
|
||||||
@ -38,12 +38,10 @@ begin
|
|||||||
formula.extend(Debrew::Formula) if args.debug?
|
formula.extend(Debrew::Formula) if args.debug?
|
||||||
|
|
||||||
ENV.extend(Stdenv)
|
ENV.extend(Stdenv)
|
||||||
T.cast(ENV, Stdenv).setup_build_environment(formula: formula, testing_formula: true)
|
ENV.setup_build_environment(formula: formula, testing_formula: true)
|
||||||
|
|
||||||
# tests can also return false to indicate failure
|
# tests can also return false to indicate failure
|
||||||
run_test = proc do
|
run_test = proc { |_ = nil| raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false }
|
||||||
raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false
|
|
||||||
end
|
|
||||||
if args.debug? # --debug is interactive
|
if args.debug? # --debug is interactive
|
||||||
run_test.call
|
run_test.call
|
||||||
else
|
else
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
# Provides helper methods for unlinking formulae and kegs with consistent output.
|
# Provides helper methods for unlinking formulae and kegs with consistent output.
|
||||||
module Unlink
|
module Unlink
|
||||||
module_function
|
def self.unlink_versioned_formulae(formula, verbose: false)
|
||||||
|
|
||||||
def unlink_versioned_formulae(formula, verbose: false)
|
|
||||||
formula.versioned_formulae
|
formula.versioned_formulae
|
||||||
.select(&:keg_only?)
|
.select(&:keg_only?)
|
||||||
.select(&:linked?)
|
.select(&:linked?)
|
||||||
@ -18,7 +16,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink(keg, dry_run: false, verbose: false)
|
def self.unlink(keg, dry_run: false, verbose: false)
|
||||||
options = { dry_run: dry_run, verbose: verbose }
|
options = { dry_run: dry_run, verbose: verbose }
|
||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "context"
|
require "context"
|
||||||
@ -42,7 +42,6 @@ module Utils
|
|||||||
--data av=#{HOMEBREW_VERSION}
|
--data av=#{HOMEBREW_VERSION}
|
||||||
]
|
]
|
||||||
metadata.each do |key, value|
|
metadata.each do |key, value|
|
||||||
next unless key
|
|
||||||
next unless value
|
next unless value
|
||||||
|
|
||||||
key = ERB::Util.url_encode key
|
key = ERB::Util.url_encode key
|
||||||
@ -146,13 +145,13 @@ module Utils
|
|||||||
report_influx(measurement, package_and_options, on_request, additional_tags_influx)
|
report_influx(measurement, package_and_options, on_request, additional_tags_influx)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(exception: Exception).void }
|
sig { params(exception: BuildError).void }
|
||||||
def report_build_error(exception)
|
def report_build_error(exception)
|
||||||
report_google_build_error(exception)
|
report_google_build_error(exception)
|
||||||
report_influx_error(exception)
|
report_influx_error(exception)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(exception: Exception).void }
|
sig { params(exception: BuildError).void }
|
||||||
def report_google_build_error(exception)
|
def report_google_build_error(exception)
|
||||||
return if not_this_run? || disabled?
|
return if not_this_run? || disabled?
|
||||||
|
|
||||||
@ -165,10 +164,10 @@ module Utils
|
|||||||
else
|
else
|
||||||
formula_full_name
|
formula_full_name
|
||||||
end
|
end
|
||||||
report_google_event("BuildError", package_and_options)
|
report_google_event(:BuildError, package_and_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(exception: Exception).void }
|
sig { params(exception: BuildError).void }
|
||||||
def report_influx_error(exception)
|
def report_influx_error(exception)
|
||||||
return if not_this_run? || disabled?
|
return if not_this_run? || disabled?
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
@ -214,7 +214,7 @@ module GitHub
|
|||||||
|
|
||||||
headers_tmpfile = Tempfile.new("github_api_headers", HOMEBREW_TEMP)
|
headers_tmpfile = Tempfile.new("github_api_headers", HOMEBREW_TEMP)
|
||||||
begin
|
begin
|
||||||
if data
|
if data_tmpfile
|
||||||
data_tmpfile.write data
|
data_tmpfile.write data
|
||||||
data_tmpfile.close
|
data_tmpfile.close
|
||||||
args += ["--data", "@#{data_tmpfile.path}"]
|
args += ["--data", "@#{data_tmpfile.path}"]
|
||||||
@ -222,7 +222,7 @@ module GitHub
|
|||||||
args += ["--request", request_method.to_s] if request_method
|
args += ["--request", request_method.to_s] if request_method
|
||||||
end
|
end
|
||||||
|
|
||||||
args += ["--dump-header", headers_tmpfile.path]
|
args += ["--dump-header", T.must(headers_tmpfile.path)]
|
||||||
|
|
||||||
output, errors, status = curl_output("--location", url.to_s, *args, secrets: [token])
|
output, errors, status = curl_output("--location", url.to_s, *args, secrets: [token])
|
||||||
output, _, http_code = output.rpartition("\n")
|
output, _, http_code = output.rpartition("\n")
|
||||||
|
5
Library/Homebrew/utils/github/api.rbi
Normal file
5
Library/Homebrew/utils/github/api.rbi
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
module GitHub::API
|
||||||
|
include Kernel
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/curl"
|
require "utils/curl"
|
||||||
|
6
Library/Homebrew/utils/repology.rbi
Normal file
6
Library/Homebrew/utils/repology.rbi
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
module Repology
|
||||||
|
include Kernel
|
||||||
|
requires_ancestor { Utils::Curl }
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user