Merge pull request #18004 from Homebrew/more-srb-strict
This commit is contained in:
commit
6105728c31
@ -743,7 +743,7 @@ module Cask
|
|||||||
def audit_github_prerelease_version
|
def audit_github_prerelease_version
|
||||||
odebug "Auditing GitHub prerelease"
|
odebug "Auditing GitHub prerelease"
|
||||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
|
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
tag = SharedAudits.github_tag_from_url(cask.url)
|
tag = SharedAudits.github_tag_from_url(cask.url)
|
||||||
tag ||= cask.version
|
tag ||= cask.version
|
||||||
@ -754,7 +754,7 @@ module Cask
|
|||||||
sig { void }
|
sig { void }
|
||||||
def audit_gitlab_prerelease_version
|
def audit_gitlab_prerelease_version
|
||||||
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
|
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
odebug "Auditing GitLab prerelease"
|
odebug "Auditing GitLab prerelease"
|
||||||
|
|
||||||
@ -770,7 +770,7 @@ module Cask
|
|||||||
return if cask.deprecated? || cask.disabled?
|
return if cask.deprecated? || cask.disabled?
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
|
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
metadata = SharedAudits.github_repo_data(user, repo)
|
metadata = SharedAudits.github_repo_data(user, repo)
|
||||||
return if metadata.nil?
|
return if metadata.nil?
|
||||||
@ -784,7 +784,7 @@ module Cask
|
|||||||
return if cask.deprecated? || cask.disabled?
|
return if cask.deprecated? || cask.disabled?
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
|
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
odebug "Auditing GitLab repo archived"
|
odebug "Auditing GitLab repo archived"
|
||||||
|
|
||||||
@ -799,7 +799,7 @@ module Cask
|
|||||||
return unless new_cask?
|
return unless new_cask?
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
|
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
odebug "Auditing GitHub repo"
|
odebug "Auditing GitHub repo"
|
||||||
|
|
||||||
@ -812,7 +812,7 @@ module Cask
|
|||||||
return unless new_cask?
|
return unless new_cask?
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*})
|
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*})
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
odebug "Auditing GitLab repo"
|
odebug "Auditing GitLab repo"
|
||||||
|
|
||||||
@ -825,7 +825,7 @@ module Cask
|
|||||||
return unless new_cask?
|
return unless new_cask?
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*})
|
user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*})
|
||||||
return if user.nil?
|
return if user.nil? || repo.nil?
|
||||||
|
|
||||||
odebug "Auditing Bitbucket repo"
|
odebug "Auditing Bitbucket repo"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
@ -21,6 +21,7 @@ module Utils
|
|||||||
|
|
||||||
alias generic_find_matching_tag find_matching_tag
|
alias generic_find_matching_tag find_matching_tag
|
||||||
|
|
||||||
|
sig { params(tag: Utils::Bottles::Tag, no_older_versions: T::Boolean).returns(T.nilable(Utils::Bottles::Tag)) }
|
||||||
def find_matching_tag(tag, no_older_versions: false)
|
def find_matching_tag(tag, no_older_versions: false)
|
||||||
# Used primarily by developers testing beta macOS releases.
|
# Used primarily by developers testing beta macOS releases.
|
||||||
if no_older_versions ||
|
if no_older_versions ||
|
||||||
@ -35,6 +36,7 @@ module Utils
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Find a bottle built for a previous version of macOS.
|
# Find a bottle built for a previous version of macOS.
|
||||||
|
sig { params(tag: Utils::Bottles::Tag).returns(T.nilable(Utils::Bottles::Tag)) }
|
||||||
def find_older_compatible_tag(tag)
|
def find_older_compatible_tag(tag)
|
||||||
tag_version = begin
|
tag_version = begin
|
||||||
tag.to_macos_version
|
tag.to_macos_version
|
||||||
|
@ -587,15 +587,13 @@ module Homebrew
|
|||||||
metadata = SharedAudits.eol_data(name, formula.version.major)
|
metadata = SharedAudits.eol_data(name, formula.version.major)
|
||||||
metadata ||= SharedAudits.eol_data(name, formula.version.major_minor)
|
metadata ||= SharedAudits.eol_data(name, formula.version.major_minor)
|
||||||
|
|
||||||
return if metadata.blank? || metadata["eol"] == false
|
return if metadata.blank? || (eol_date = metadata["eol"]).blank?
|
||||||
|
|
||||||
see_url = "see #{Formatter.url("https://endoflife.date/#{name}")}"
|
message = "Product is EOL"
|
||||||
if metadata["eol"] == true
|
message += " since #{eol_date}" if Date.parse(eol_date.to_s) <= Date.today
|
||||||
problem "Product is EOL, #{see_url}"
|
message += ", see #{Formatter.url("https://endoflife.date/#{name}")}"
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
problem "Product is EOL since #{metadata["eol"]}, #{see_url}" if Date.parse(metadata["eol"]) <= Date.today
|
problem message
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_wayback_url
|
def audit_wayback_url
|
||||||
@ -783,8 +781,8 @@ module Homebrew
|
|||||||
problem "#{stable.version} is a development release"
|
problem "#{stable.version} is a development release"
|
||||||
|
|
||||||
when %r{https?://gitlab\.com/([\w-]+)/([\w-]+)}
|
when %r{https?://gitlab\.com/([\w-]+)/([\w-]+)}
|
||||||
owner = Regexp.last_match(1)
|
owner = T.must(Regexp.last_match(1))
|
||||||
repo = Regexp.last_match(2)
|
repo = T.must(Regexp.last_match(2))
|
||||||
|
|
||||||
tag = SharedAudits.gitlab_tag_from_url(url)
|
tag = SharedAudits.gitlab_tag_from_url(url)
|
||||||
tag ||= stable.specs[:tag]
|
tag ||= stable.specs[:tag]
|
||||||
@ -795,8 +793,8 @@ module Homebrew
|
|||||||
problem error if error
|
problem error if error
|
||||||
end
|
end
|
||||||
when %r{^https://github.com/([\w-]+)/([\w-]+)}
|
when %r{^https://github.com/([\w-]+)/([\w-]+)}
|
||||||
owner = Regexp.last_match(1)
|
owner = T.must(Regexp.last_match(1))
|
||||||
repo = Regexp.last_match(2)
|
repo = T.must(Regexp.last_match(2))
|
||||||
tag = SharedAudits.github_tag_from_url(url)
|
tag = SharedAudits.github_tag_from_url(url)
|
||||||
tag ||= formula.stable.specs[:tag]
|
tag ||= formula.stable.specs[:tag]
|
||||||
|
|
||||||
|
@ -1,27 +1,33 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Helper for checking if a file is considered a metadata file.
|
# Helper for checking if a file is considered a metadata file.
|
||||||
module Metafiles
|
module Metafiles
|
||||||
LICENSES = Set.new(%w[copying copyright license licence]).freeze
|
LICENSES = T.let(Set.new(%w[copying copyright license licence]).freeze, T::Set[String])
|
||||||
# {https://github.com/github/markup#markups}
|
# {https://github.com/github/markup#markups}
|
||||||
EXTENSIONS = Set.new(%w[
|
EXTENSIONS = T.let(Set.new(%w[
|
||||||
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
|
.adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn
|
||||||
.org .pod .rdoc .rst .rtf .textile .txt .wiki
|
.org .pod .rdoc .rst .rtf .textile .txt .wiki
|
||||||
]).freeze
|
]).freeze, T::Set[String])
|
||||||
BASENAMES = Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze
|
BASENAMES = T.let(Set.new(%w[
|
||||||
|
about authors changelog changes history news notes notice readme todo
|
||||||
|
]).freeze, T::Set[String])
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
sig { params(file: String).returns(T::Boolean) }
|
||||||
def list?(file)
|
def list?(file)
|
||||||
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
|
return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file)
|
||||||
|
|
||||||
!copy?(file)
|
!copy?(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(file: String).returns(T::Boolean) }
|
||||||
def copy?(file)
|
def copy?(file)
|
||||||
file = file.downcase
|
file = file.downcase
|
||||||
return true if LICENSES.include? file.split(/\.|-/).first
|
license = file.split(/\.|-/).first
|
||||||
|
return false unless license
|
||||||
|
return true if LICENSES.include?(license)
|
||||||
|
|
||||||
ext = File.extname(file)
|
ext = File.extname(file)
|
||||||
file = File.basename(file, ext) if EXTENSIONS.include?(ext)
|
file = File.basename(file, ext) if EXTENSIONS.include?(ext)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "formulary"
|
require "formulary"
|
||||||
@ -7,11 +7,13 @@ module Homebrew
|
|||||||
# Helper module for checking if there is a reason a formula is missing.
|
# Helper module for checking if there is a reason a formula is missing.
|
||||||
module MissingFormula
|
module MissingFormula
|
||||||
class << self
|
class << self
|
||||||
|
sig { params(name: String, silent: T::Boolean, show_info: T::Boolean).returns(T.nilable(String)) }
|
||||||
def reason(name, silent: false, show_info: false)
|
def reason(name, silent: false, show_info: false)
|
||||||
cask_reason(name, silent:, show_info:) || disallowed_reason(name) ||
|
cask_reason(name, silent:, show_info:) || disallowed_reason(name) ||
|
||||||
tap_migration_reason(name) || deleted_reason(name, silent:)
|
tap_migration_reason(name) || deleted_reason(name, silent:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(name: String).returns(T.nilable(String)) }
|
||||||
def disallowed_reason(name)
|
def disallowed_reason(name)
|
||||||
case name.downcase
|
case name.downcase
|
||||||
when "gem", /^rubygems?$/ then <<~EOS
|
when "gem", /^rubygems?$/ then <<~EOS
|
||||||
@ -93,6 +95,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
alias generic_disallowed_reason disallowed_reason
|
alias generic_disallowed_reason disallowed_reason
|
||||||
|
|
||||||
|
sig { params(name: String).returns(T.nilable(String)) }
|
||||||
def tap_migration_reason(name)
|
def tap_migration_reason(name)
|
||||||
message = T.let(nil, T.nilable(String))
|
message = T.let(nil, T.nilable(String))
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ module Homebrew
|
|||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(name: String, silent: T::Boolean).returns(T.nilable(String)) }
|
||||||
def deleted_reason(name, silent: false)
|
def deleted_reason(name, silent: false)
|
||||||
path = Formulary.path name
|
path = Formulary.path name
|
||||||
return if File.exist? path
|
return if File.exist? path
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
@ -16,6 +16,7 @@ module Readall
|
|||||||
|
|
||||||
private_class_method :cache
|
private_class_method :cache
|
||||||
|
|
||||||
|
sig { params(ruby_files: T::Array[Pathname]).returns(T::Boolean) }
|
||||||
def self.valid_ruby_syntax?(ruby_files)
|
def self.valid_ruby_syntax?(ruby_files)
|
||||||
failed = T.let(false, T::Boolean)
|
failed = T.let(false, T::Boolean)
|
||||||
ruby_files.each do |ruby_file|
|
ruby_files.each do |ruby_file|
|
||||||
@ -25,6 +26,7 @@ module Readall
|
|||||||
!failed
|
!failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(alias_dir: Pathname, formula_dir: Pathname).returns(T::Boolean) }
|
||||||
def self.valid_aliases?(alias_dir, formula_dir)
|
def self.valid_aliases?(alias_dir, formula_dir)
|
||||||
return true unless alias_dir.directory?
|
return true unless alias_dir.directory?
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ module Readall
|
|||||||
!failed
|
!failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(tap: Tap, bottle_tag: T.nilable(Utils::Bottles::Tag)).returns(T::Boolean) }
|
||||||
def self.valid_formulae?(tap, bottle_tag: nil)
|
def self.valid_formulae?(tap, bottle_tag: nil)
|
||||||
cache[:valid_formulae] ||= {}
|
cache[:valid_formulae] ||= {}
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ module Readall
|
|||||||
next if valid == true || valid&.include?(bottle_tag)
|
next if valid == true || valid&.include?(bottle_tag)
|
||||||
|
|
||||||
formula_name = file.basename(".rb").to_s
|
formula_name = file.basename(".rb").to_s
|
||||||
formula_contents = file.read(encoding: "UTF-8")
|
formula_contents = file.read.force_encoding("UTF-8")
|
||||||
|
|
||||||
readall_namespace = "ReadallNamespace"
|
readall_namespace = "ReadallNamespace"
|
||||||
readall_formula_class = Formulary.load_formula(formula_name, file, formula_contents, readall_namespace,
|
readall_formula_class = Formulary.load_formula(formula_name, file, formula_contents, readall_namespace,
|
||||||
@ -79,10 +82,16 @@ module Readall
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(_tap: Tap, os_name: T.nilable(Symbol), arch: T.nilable(Symbol)).returns(T::Boolean) }
|
||||||
def self.valid_casks?(_tap, os_name: nil, arch: nil)
|
def self.valid_casks?(_tap, os_name: nil, arch: nil)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
tap: Tap, aliases: T::Boolean, no_simulate: T::Boolean, os_arch_combinations: T::Array[T::Array[String]],
|
||||||
|
).returns(T::Boolean)
|
||||||
|
}
|
||||||
def self.valid_tap?(tap, aliases: false, no_simulate: false,
|
def self.valid_tap?(tap, aliases: false, no_simulate: false,
|
||||||
os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS)
|
os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS)
|
||||||
success = true
|
success = true
|
||||||
@ -110,6 +119,7 @@ module Readall
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(filename: Pathname).returns(T::Boolean) }
|
||||||
private_class_method def self.syntax_errors_or_warnings?(filename)
|
private_class_method def self.syntax_errors_or_warnings?(filename)
|
||||||
# Retrieve messages about syntax errors/warnings printed to `$stderr`.
|
# Retrieve messages about syntax errors/warnings printed to `$stderr`.
|
||||||
_, err, status = system_command(RUBY_PATH, args: ["-c", "-w", filename], print_stderr: false)
|
_, err, status = system_command(RUBY_PATH, args: ["-c", "-w", filename], print_stderr: false)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# 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
|
||||||
|
sig { params(formula: Formula, verbose: T::Boolean).void }
|
||||||
def self.unlink_versioned_formulae(formula, verbose: false)
|
def self.unlink_versioned_formulae(formula, verbose: false)
|
||||||
formula.versioned_formulae
|
formula.versioned_formulae
|
||||||
.select(&:keg_only?)
|
.select(&:keg_only?)
|
||||||
@ -15,6 +16,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(keg: Keg, dry_run: T::Boolean, verbose: T::Boolean).void }
|
||||||
def self.unlink(keg, dry_run: false, verbose: false)
|
def self.unlink(keg, dry_run: false, verbose: false)
|
||||||
options = { dry_run:, verbose: }
|
options = { dry_run:, verbose: }
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
# Helper functions for creating symlinks.
|
# Helper functions for creating symlinks.
|
||||||
module Link
|
module Link
|
||||||
|
sig { params(src_dir: Pathname, dst_dir: Pathname, command: String, link_dir: T::Boolean).void }
|
||||||
def self.link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
|
def self.link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
|
||||||
return unless src_dir.exist?
|
return unless src_dir.exist?
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ module Utils
|
|||||||
end
|
end
|
||||||
private_class_method :link_src_dst_dirs
|
private_class_method :link_src_dst_dirs
|
||||||
|
|
||||||
|
sig { params(src_dir: Pathname, dst_dir: Pathname, unlink_dir: T::Boolean).void }
|
||||||
def self.unlink_src_dst_dirs(src_dir, dst_dir, unlink_dir: false)
|
def self.unlink_src_dst_dirs(src_dir, dst_dir, unlink_dir: false)
|
||||||
return unless src_dir.exist?
|
return unless src_dir.exist?
|
||||||
|
|
||||||
@ -52,26 +54,31 @@ module Utils
|
|||||||
end
|
end
|
||||||
private_class_method :unlink_src_dst_dirs
|
private_class_method :unlink_src_dst_dirs
|
||||||
|
|
||||||
|
sig { params(path: Pathname, command: String).void }
|
||||||
def self.link_manpages(path, command)
|
def self.link_manpages(path, command)
|
||||||
link_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1", command)
|
link_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1", command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(path: Pathname).void }
|
||||||
def self.unlink_manpages(path)
|
def self.unlink_manpages(path)
|
||||||
unlink_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1")
|
unlink_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(path: Pathname, command: String).void }
|
||||||
def self.link_completions(path, command)
|
def self.link_completions(path, command)
|
||||||
link_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d", command)
|
link_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d", command)
|
||||||
link_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions", command)
|
link_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions", command)
|
||||||
link_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d", command)
|
link_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d", command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(path: Pathname).void }
|
||||||
def self.unlink_completions(path)
|
def self.unlink_completions(path)
|
||||||
unlink_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d")
|
unlink_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d")
|
||||||
unlink_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions")
|
unlink_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions")
|
||||||
unlink_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
unlink_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(path: Pathname, command: String).void }
|
||||||
def self.link_docs(path, command)
|
def self.link_docs(path, command)
|
||||||
link_src_dst_dirs(path/"docs", HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true)
|
link_src_dst_dirs(path/"docs", HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true)
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
@ -27,7 +27,7 @@ module Utils
|
|||||||
return @launchctl if defined? @launchctl
|
return @launchctl if defined? @launchctl
|
||||||
return if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
return if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
||||||
|
|
||||||
@launchctl = which("launchctl")
|
@launchctl = T.let(which("launchctl"), T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Path to systemctl binary.
|
# Path to systemctl binary.
|
||||||
@ -36,7 +36,7 @@ module Utils
|
|||||||
return @systemctl if defined? @systemctl
|
return @systemctl if defined? @systemctl
|
||||||
return if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
return if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
||||||
|
|
||||||
@systemctl = which("systemctl")
|
@systemctl = T.let(which("systemctl"), T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/curl"
|
require "utils/curl"
|
||||||
@ -10,8 +10,9 @@ module SharedAudits
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
sig { params(product: String, cycle: String).returns(T.nilable(T::Hash[String, T::Hash[Symbol, T.untyped]])) }
|
||||||
def eol_data(product, cycle)
|
def eol_data(product, cycle)
|
||||||
@eol_data ||= {}
|
@eol_data ||= T.let({}, T.nilable(T::Hash[String, T::Hash[String, T.untyped]]))
|
||||||
@eol_data["#{product}/#{cycle}"] ||= begin
|
@eol_data["#{product}/#{cycle}"] ||= begin
|
||||||
out, _, status = Utils::Curl.curl_output("--location", "https://endoflife.date/api/#{product}/#{cycle}.json")
|
out, _, status = Utils::Curl.curl_output("--location", "https://endoflife.date/api/#{product}/#{cycle}.json")
|
||||||
json = JSON.parse(out) if status.success?
|
json = JSON.parse(out) if status.success?
|
||||||
@ -20,8 +21,9 @@ module SharedAudits
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String).returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||||
def github_repo_data(user, repo)
|
def github_repo_data(user, repo)
|
||||||
@github_repo_data ||= {}
|
@github_repo_data ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
||||||
@github_repo_data["#{user}/#{repo}"] ||= GitHub.repository(user, repo)
|
@github_repo_data["#{user}/#{repo}"] ||= GitHub.repository(user, repo)
|
||||||
|
|
||||||
@github_repo_data["#{user}/#{repo}"]
|
@github_repo_data["#{user}/#{repo}"]
|
||||||
@ -31,10 +33,11 @@ module SharedAudits
|
|||||||
raise unless e.message.match?(GitHub::API::GITHUB_IP_ALLOWLIST_ERROR)
|
raise unless e.message.match?(GitHub::API::GITHUB_IP_ALLOWLIST_ERROR)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String, tag: String).returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||||
def github_release_data(user, repo, tag)
|
def github_release_data(user, repo, tag)
|
||||||
id = "#{user}/#{repo}/#{tag}"
|
id = "#{user}/#{repo}/#{tag}"
|
||||||
url = "#{GitHub::API_URL}/repos/#{user}/#{repo}/releases/tags/#{tag}"
|
url = "#{GitHub::API_URL}/repos/#{user}/#{repo}/releases/tags/#{tag}"
|
||||||
@github_release_data ||= {}
|
@github_release_data ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
||||||
@github_release_data[id] ||= GitHub::API.open_rest(url)
|
@github_release_data[id] ||= GitHub::API.open_rest(url)
|
||||||
|
|
||||||
@github_release_data[id]
|
@github_release_data[id]
|
||||||
@ -44,6 +47,13 @@ module SharedAudits
|
|||||||
raise unless e.message.match?(GitHub::API::GITHUB_IP_ALLOWLIST_ERROR)
|
raise unless e.message.match?(GitHub::API::GITHUB_IP_ALLOWLIST_ERROR)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
user: String, repo: String, tag: String, formula: T.nilable(Formula), cask: T.nilable(Cask::Cask),
|
||||||
|
).returns(
|
||||||
|
T.nilable(String),
|
||||||
|
)
|
||||||
|
}
|
||||||
def github_release(user, repo, tag, formula: nil, cask: nil)
|
def github_release(user, repo, tag, formula: nil, cask: nil)
|
||||||
release = github_release_data(user, repo, tag)
|
release = github_release_data(user, repo, tag)
|
||||||
return unless release
|
return unless release
|
||||||
@ -63,8 +73,9 @@ module SharedAudits
|
|||||||
"#{tag} is a GitHub draft." if release["draft"]
|
"#{tag} is a GitHub draft." if release["draft"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String).returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||||
def gitlab_repo_data(user, repo)
|
def gitlab_repo_data(user, repo)
|
||||||
@gitlab_repo_data ||= {}
|
@gitlab_repo_data ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
||||||
@gitlab_repo_data["#{user}/#{repo}"] ||= begin
|
@gitlab_repo_data["#{user}/#{repo}"] ||= begin
|
||||||
out, _, status = Utils::Curl.curl_output("https://gitlab.com/api/v4/projects/#{user}%2F#{repo}")
|
out, _, status = Utils::Curl.curl_output("https://gitlab.com/api/v4/projects/#{user}%2F#{repo}")
|
||||||
json = JSON.parse(out) if status.success?
|
json = JSON.parse(out) if status.success?
|
||||||
@ -73,9 +84,10 @@ module SharedAudits
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String, tag: String).returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||||
def gitlab_release_data(user, repo, tag)
|
def gitlab_release_data(user, repo, tag)
|
||||||
id = "#{user}/#{repo}/#{tag}"
|
id = "#{user}/#{repo}/#{tag}"
|
||||||
@gitlab_release_data ||= {}
|
@gitlab_release_data ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
||||||
@gitlab_release_data[id] ||= begin
|
@gitlab_release_data[id] ||= begin
|
||||||
out, _, status = Utils::Curl.curl_output(
|
out, _, status = Utils::Curl.curl_output(
|
||||||
"https://gitlab.com/api/v4/projects/#{user}%2F#{repo}/releases/#{tag}", "--fail"
|
"https://gitlab.com/api/v4/projects/#{user}%2F#{repo}/releases/#{tag}", "--fail"
|
||||||
@ -84,6 +96,13 @@ module SharedAudits
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
user: String, repo: String, tag: String, formula: T.nilable(Formula), cask: T.nilable(Cask::Cask),
|
||||||
|
).returns(
|
||||||
|
T.nilable(String),
|
||||||
|
)
|
||||||
|
}
|
||||||
def gitlab_release(user, repo, tag, formula: nil, cask: nil)
|
def gitlab_release(user, repo, tag, formula: nil, cask: nil)
|
||||||
release = gitlab_release_data(user, repo, tag)
|
release = gitlab_release_data(user, repo, tag)
|
||||||
return unless release
|
return unless release
|
||||||
@ -100,6 +119,7 @@ module SharedAudits
|
|||||||
"#{tag} is a GitLab pre-release."
|
"#{tag} is a GitLab pre-release."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String).returns(T.nilable(String)) }
|
||||||
def github(user, repo)
|
def github(user, repo)
|
||||||
metadata = github_repo_data(user, repo)
|
metadata = github_repo_data(user, repo)
|
||||||
|
|
||||||
@ -117,6 +137,7 @@ module SharedAudits
|
|||||||
"GitHub repository too new (<30 days old)"
|
"GitHub repository too new (<30 days old)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String).returns(T.nilable(String)) }
|
||||||
def gitlab(user, repo)
|
def gitlab(user, repo)
|
||||||
metadata = gitlab_repo_data(user, repo)
|
metadata = gitlab_repo_data(user, repo)
|
||||||
|
|
||||||
@ -132,6 +153,7 @@ module SharedAudits
|
|||||||
"GitLab repository too new (<30 days old)"
|
"GitLab repository too new (<30 days old)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(user: String, repo: String).returns(T.nilable(String)) }
|
||||||
def bitbucket(user, repo)
|
def bitbucket(user, repo)
|
||||||
api_url = "https://api.bitbucket.org/2.0/repositories/#{user}/#{repo}"
|
api_url = "https://api.bitbucket.org/2.0/repositories/#{user}/#{repo}"
|
||||||
out, _, status = Utils::Curl.curl_output("--request", "GET", api_url)
|
out, _, status = Utils::Curl.curl_output("--request", "GET", api_url)
|
||||||
@ -163,6 +185,7 @@ module SharedAudits
|
|||||||
"Bitbucket repository not notable enough (<30 forks and <75 watchers)"
|
"Bitbucket repository not notable enough (<30 forks and <75 watchers)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(url: String).returns(T.nilable(String)) }
|
||||||
def github_tag_from_url(url)
|
def github_tag_from_url(url)
|
||||||
url = url.to_s
|
url = url.to_s
|
||||||
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/refs/tags/([^/]+)\.(tar\.gz|zip)$})
|
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/refs/tags/([^/]+)\.(tar\.gz|zip)$})
|
||||||
@ -174,6 +197,7 @@ module SharedAudits
|
|||||||
tag
|
tag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(url: String).returns(T.nilable(String)) }
|
||||||
def gitlab_tag_from_url(url)
|
def gitlab_tag_from_url(url)
|
||||||
url = url.to_s
|
url = url.to_s
|
||||||
url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
|
url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "system_command"
|
require "system_command"
|
||||||
@ -19,7 +19,7 @@ module Utils
|
|||||||
return @version if defined?(@version)
|
return @version if defined?(@version)
|
||||||
|
|
||||||
stdout, _, status = system_command(HOMEBREW_SHIMS_PATH/"shared/svn", args: ["--version"], print_stderr: false)
|
stdout, _, status = system_command(HOMEBREW_SHIMS_PATH/"shared/svn", args: ["--version"], print_stderr: false)
|
||||||
@version = status.success? ? stdout.chomp[/svn, version (\d+(?:\.\d+)*)/, 1] : nil
|
@version = T.let(status.success? ? stdout.chomp[/svn, version (\d+(?:\.\d+)*)/, 1] : nil, T.nilable(String))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(url: String).returns(T::Boolean) }
|
sig { params(url: String).returns(T::Boolean) }
|
||||||
@ -34,7 +34,7 @@ module Utils
|
|||||||
system_command("svn", args: args.concat(invalid_cert_flags), print_stderr: false).success?
|
system_command("svn", args: args.concat(invalid_cert_flags), print_stderr: false).success?
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(Array) }
|
sig { returns(T::Array[String]) }
|
||||||
def invalid_cert_flags
|
def invalid_cert_flags
|
||||||
opoo "Ignoring Subversion certificate errors!"
|
opoo "Ignoring Subversion certificate errors!"
|
||||||
args = ["--non-interactive", "--trust-server-cert"]
|
args = ["--non-interactive", "--trust-server-cert"]
|
||||||
@ -44,6 +44,7 @@ module Utils
|
|||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def clear_version_cache
|
def clear_version_cache
|
||||||
remove_instance_variable(:@version) if defined?(@version)
|
remove_instance_variable(:@version) if defined?(@version)
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
@ -29,6 +29,6 @@ class User < SimpleDelegator
|
|||||||
pwuid = Etc.getpwuid(Process.euid)
|
pwuid = Etc.getpwuid(Process.euid)
|
||||||
return if pwuid.nil?
|
return if pwuid.nil?
|
||||||
|
|
||||||
@current = new(pwuid.name)
|
@current = T.let(new(pwuid.name), T.nilable(T.attached_class))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user