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
|
||||
|
||||
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: false
|
||||
|
||||
class URL
|
||||
include Kernel
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "keg"
|
||||
@ -31,7 +31,7 @@ module Homebrew
|
||||
|
||||
def self.checks(type, fatal: true)
|
||||
@checks ||= Checks.new
|
||||
failed = false
|
||||
failed = T.let(false, T::Boolean)
|
||||
@checks.public_send(type).each do |check|
|
||||
out = @checks.public_send(check)
|
||||
next if out.nil?
|
||||
@ -64,6 +64,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(list: T::Array[String], string: String).returns(String) }
|
||||
def inject_file_list(list, string)
|
||||
list.reduce(string.dup) { |acc, elem| acc << " #{elem}\n" }
|
||||
.freeze
|
||||
@ -642,10 +643,11 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
sig { returns(T.nilable(String)) }
|
||||
def check_git_status
|
||||
return unless Utils::Git.available?
|
||||
|
||||
message = nil
|
||||
message = T.let(nil, T.nilable(String))
|
||||
|
||||
repos = {
|
||||
"Homebrew/brew" => HOMEBREW_REPOSITORY,
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
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
|
||||
|
||||
class Keg
|
||||
@ -44,7 +44,7 @@ class Keg
|
||||
key.is_a?(String) ? key.length : 999
|
||||
end.reverse
|
||||
|
||||
any_changed = false
|
||||
any_changed = T.let(nil, T.nilable(String))
|
||||
sorted_keys.each do |key|
|
||||
changed = text.gsub!(key, replacements[key])
|
||||
any_changed ||= changed
|
||||
@ -144,7 +144,7 @@ class Keg
|
||||
def replace_text_in_files(relocation, files: nil)
|
||||
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|
|
||||
s = first.open("rb", &:read)
|
||||
|
||||
@ -179,11 +179,11 @@ class Keg
|
||||
binary = File.binread file
|
||||
odebug "Replacing build prefix in: #{file}"
|
||||
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.
|
||||
match_indices.each do |i|
|
||||
s = binary_strings[i]
|
||||
s = binary_strings.fetch(i)
|
||||
binary_strings[i] = s.gsub(old_prefix, new_prefix)
|
||||
.ljust(s.size, NULL_BYTE)
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
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
|
||||
|
||||
raise "#{__FILE__} must not be loaded via `require`." if $PROGRAM_NAME != __FILE__
|
||||
@ -38,12 +38,10 @@ begin
|
||||
formula.extend(Debrew::Formula) if args.debug?
|
||||
|
||||
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
|
||||
run_test = proc do
|
||||
raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false
|
||||
end
|
||||
run_test = proc { |_ = nil| raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false }
|
||||
if args.debug? # --debug is interactive
|
||||
run_test.call
|
||||
else
|
||||
|
@ -1,12 +1,10 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
# Provides helper methods for unlinking formulae and kegs with consistent output.
|
||||
module Unlink
|
||||
module_function
|
||||
|
||||
def unlink_versioned_formulae(formula, verbose: false)
|
||||
def self.unlink_versioned_formulae(formula, verbose: false)
|
||||
formula.versioned_formulae
|
||||
.select(&:keg_only?)
|
||||
.select(&:linked?)
|
||||
@ -18,7 +16,7 @@ module Homebrew
|
||||
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 }
|
||||
|
||||
keg.lock do
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "context"
|
||||
@ -42,7 +42,6 @@ module Utils
|
||||
--data av=#{HOMEBREW_VERSION}
|
||||
]
|
||||
metadata.each do |key, value|
|
||||
next unless key
|
||||
next unless value
|
||||
|
||||
key = ERB::Util.url_encode key
|
||||
@ -146,13 +145,13 @@ module Utils
|
||||
report_influx(measurement, package_and_options, on_request, additional_tags_influx)
|
||||
end
|
||||
|
||||
sig { params(exception: Exception).void }
|
||||
sig { params(exception: BuildError).void }
|
||||
def report_build_error(exception)
|
||||
report_google_build_error(exception)
|
||||
report_influx_error(exception)
|
||||
end
|
||||
|
||||
sig { params(exception: Exception).void }
|
||||
sig { params(exception: BuildError).void }
|
||||
def report_google_build_error(exception)
|
||||
return if not_this_run? || disabled?
|
||||
|
||||
@ -165,10 +164,10 @@ module Utils
|
||||
else
|
||||
formula_full_name
|
||||
end
|
||||
report_google_event("BuildError", package_and_options)
|
||||
report_google_event(:BuildError, package_and_options)
|
||||
end
|
||||
|
||||
sig { params(exception: Exception).void }
|
||||
sig { params(exception: BuildError).void }
|
||||
def report_influx_error(exception)
|
||||
return if not_this_run? || disabled?
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "tempfile"
|
||||
@ -214,7 +214,7 @@ module GitHub
|
||||
|
||||
headers_tmpfile = Tempfile.new("github_api_headers", HOMEBREW_TEMP)
|
||||
begin
|
||||
if data
|
||||
if data_tmpfile
|
||||
data_tmpfile.write data
|
||||
data_tmpfile.close
|
||||
args += ["--data", "@#{data_tmpfile.path}"]
|
||||
@ -222,7 +222,7 @@ module GitHub
|
||||
args += ["--request", request_method.to_s] if request_method
|
||||
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, _, 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
|
||||
|
||||
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