language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
Homebrew
brew
76e52ebe6241dec256e7c62aeb716aee5a9740ea.json
pr-pull: fix empty workflow check workflow_run is an array, which first element is the json returned by the github API. We need to check that first element if we want to know if the workflow exists.
Library/Homebrew/dev-cmd/pr-pull.rb
@@ -419,9 +419,10 @@ def pr_pull ) if args.ignore_missing_artifacts.present? && args.ignore_missing_artifacts.include?(workflow) && - workflow_run.empty? + workflow_run.first.blank? # Ignore that workflow as it was not executed and we specified # that we could skip it. + ohai "Ignoring workflow #{workflow} as requested by --ignore-missing-artifacts" next end
false
Other
Homebrew
brew
fd08ffdd67691b99bf3d6fd598ed40ef433d4c8b.json
cmd/update.sh: update Git logic. Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Library/Homebrew/cmd/update.sh
@@ -383,9 +383,7 @@ EOS ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] then ohai "Installing Homebrew Git" - [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git - unset GIT_EXECUTABLE - if ! git --version &>/dev/null + if [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && ! brew install git then odie "Git must be installed and in your PATH!" fi
false
Other
Homebrew
brew
20de58b5ae473939e9a39d4e79c3a6f7601d6bf1.json
bump-formula-pr: use new update_python_resources! signature
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -336,7 +336,7 @@ def bump_formula_pr end unless args.dry_run? - resources_checked = PyPI.update_python_resources! formula, new_formula_version, + resources_checked = PyPI.update_python_resources! formula, version: new_formula_version, silent: args.quiet?, ignore_non_pypi_packages: true end
false
Other
Homebrew
brew
51a1b7c9e1b39e19cc93cb9e40017218a1d2d8cd.json
move pypi list to tap formula_lists directory
Library/Homebrew/dev-cmd/update-python-resources.rb
@@ -27,7 +27,6 @@ def update_python_resources_args description: "Use the specified <version> when finding resources for <formula>. "\ "If no version is specified, the current version for <formula> will be used." flag "--package-name=", - depends_on: "--version", description: "Use the specified <package-name> when finding resources for <formula>. "\ "If no package name is specified, it will be inferred from the formula's stable URL." comma_array "--extra-packages=",
true
Other
Homebrew
brew
51a1b7c9e1b39e19cc93cb9e40017218a1d2d8cd.json
move pypi list to tap formula_lists directory
Library/Homebrew/tap.rb
@@ -21,11 +21,13 @@ class Tap HOMEBREW_TAP_FORMULA_RENAMES_FILE = "formula_renames.json" HOMEBREW_TAP_MIGRATIONS_FILE = "tap_migrations.json" HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR = "audit_exceptions" + HOMEBREW_TAP_FORMULA_LISTS_DIR = "formula_lists" HOMEBREW_TAP_JSON_FILES = %W[ #{HOMEBREW_TAP_FORMULA_RENAMES_FILE} #{HOMEBREW_TAP_MIGRATIONS_FILE} #{HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR}/*.json + #{HOMEBREW_TAP_FORMULA_LISTS_DIR}/*.json ].freeze def self.fetch(*args) @@ -112,6 +114,7 @@ def clear_cache @formula_renames = nil @tap_migrations = nil @audit_exceptions = nil + @formula_lists = nil @config = nil remove_instance_variable(:@private) if instance_variable_defined?(:@private) end @@ -560,22 +563,12 @@ def tap_migrations # Hash with audit exceptions def audit_exceptions - @audit_exceptions = {} - - Pathname.glob(path/HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR/"*").each do |exception_file| - list_name = exception_file.basename.to_s.chomp(".json").to_sym - list_contents = begin - JSON.parse exception_file.read - rescue JSON::ParserError - opoo "#{exception_file} contains invalid JSON" - end - - next if list_contents.nil? - - @audit_exceptions[list_name] = list_contents - end + @audit_exceptions = read_formula_list_directory HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR + end - @audit_exceptions + # Hash with formula lists + def formula_lists + @formula_lists = read_formula_list_directory HOMEBREW_TAP_FORMULA_LISTS_DIR end def ==(other) @@ -636,6 +629,25 @@ def read_or_set_private_config end end end + + def read_formula_list_directory(directory) + list = {} + + Pathname.glob(path/directory/"*").each do |exception_file| + list_name = exception_file.basename.to_s.chomp(".json").to_sym + list_contents = begin + JSON.parse exception_file.read + rescue JSON::ParserError + opoo "#{exception_file} contains invalid JSON" + end + + next if list_contents.nil? + + list[list_name] = list_contents + end + + list + end end # A specialized {Tap} class for the core formulae. @@ -739,6 +751,13 @@ def audit_exceptions end end + def formula_lists + @formula_lists ||= begin + self.class.ensure_installed! + super + end + end + # @private def formula_file_to_name(file) file.basename(".rb").to_s
true
Other
Homebrew
brew
51a1b7c9e1b39e19cc93cb9e40017218a1d2d8cd.json
move pypi list to tap formula_lists directory
Library/Homebrew/tap_auditor.rb
@@ -15,13 +15,14 @@ def initialize(tap, strict:) @name = tap.name @path = tap.path @tap_audit_exceptions = tap.audit_exceptions + @tap_formula_lists = tap.formula_lists @problems = [] end sig { void } def audit audit_json_files - audit_tap_audit_exceptions + audit_tap_formula_lists end sig { void } @@ -35,32 +36,38 @@ def audit_json_files end sig { void } - def audit_tap_audit_exceptions - @tap_audit_exceptions.each do |list_name, formula_names| - unless [Hash, Array].include? formula_names.class - problem <<~EOS - audit_exceptions/#{list_name}.json should contain a JSON array - of formula names or a JSON object mapping formula names to values - EOS - next - end + def audit_tap_formula_lists + tap_lists = { + audit_exceptions: @tap_audit_exceptions, + formula_lists: @tap_formula_lists, + } + tap_lists.each do |list_directory, list| + list.each do |list_name, formula_names| + unless [Hash, Array].include? formula_names.class + problem <<~EOS + #{list_directory}/#{list_name}.json should contain a JSON array + of formula names or a JSON object mapping formula names to values + EOS + next + end - formula_names = formula_names.keys if formula_names.is_a? Hash + formula_names = formula_names.keys if formula_names.is_a? Hash - invalid_formulae = [] - formula_names.each do |name| - invalid_formulae << name if Formula[name].tap != @name - rescue FormulaUnavailableError - invalid_formulae << name - end + invalid_formulae = [] + formula_names.each do |name| + invalid_formulae << name if Formula[name].tap != @name + rescue FormulaUnavailableError + invalid_formulae << name + end - next if invalid_formulae.empty? + next if invalid_formulae.empty? - problem <<~EOS - audit_exceptions/#{list_name}.json references - formulae that are not found in the #{@name} tap. - Invalid formulae: #{invalid_formulae.join(", ")} - EOS + problem <<~EOS + #{list_directory}/#{list_name}.json references + formulae that are not found in the #{@name} tap. + Invalid formulae: #{invalid_formulae.join(", ")} + EOS + end end end
true
Other
Homebrew
brew
51a1b7c9e1b39e19cc93cb9e40017218a1d2d8cd.json
move pypi list to tap formula_lists directory
Library/Homebrew/utils/pypi.rb
@@ -26,8 +26,9 @@ def update_pypi_url(url, version) url end - # Get name, URL and SHA-256 checksum for a given PyPI package. - def get_pypi_info(package, version) + # Get name, URL, SHA-256 checksum, and latest version for a given PyPI package. + def get_pypi_info(package, version = nil) + package = package.split("[").first metadata_url = if version.present? "https://pypi.org/pypi/#{package}/#{version}/json" else @@ -46,15 +47,15 @@ def get_pypi_info(package, version) sdist = json["urls"].find { |url| url["packagetype"] == "sdist" } return json["info"]["name"] if sdist.nil? - [json["info"]["name"], sdist["url"], sdist["digests"]["sha256"]] + [json["info"]["name"], sdist["url"], sdist["digests"]["sha256"], json["info"]["version"]] end # Return true if resources were checked (even if no change). def update_python_resources!(formula, version: nil, package_name: nil, extra_packages: nil, exclude_packages: nil, print_only: false, silent: false, ignore_non_pypi_packages: false) - auto_update_list = formula.tap.audit_exceptions[:automatic_resource_update_list] - if package_name.blank? && extra_packages.blank? && !print_only && + auto_update_list = formula.tap.formula_lists[:pypi_automatic_resource_update_list] + if package_name.blank? && extra_packages.blank? && exclude_packages.blank? && !print_only && auto_update_list.present? && auto_update_list.key?(formula.full_name) list_entry = auto_update_list[formula.full_name] @@ -70,18 +71,12 @@ def update_python_resources!(formula, version: nil, package_name: nil, extra_pac end end + version ||= formula.version if package_name.blank? package_name ||= url_to_pypi_package_name formula.stable.url - version ||= formula.version extra_packages ||= [] exclude_packages ||= [] - # opoo "package_name: #{package_name}" - # opoo "version: #{version}" - # opoo "extra_packages: #{extra_packages}" - # opoo "exclude_packages: #{exclude_packages}" - # odie "" - - if package_name.nil? + if package_name.blank? return if ignore_non_pypi_packages odie <<~EOS @@ -140,19 +135,19 @@ def update_python_resources!(formula, version: nil, package_name: nil, extra_pac EOS end - found_packages.merge!(JSON.parse(pipgrip_output).sort.to_h) do |conflicting_package, old_version, new_version| + found_packages.merge!(JSON.parse(pipgrip_output).to_h) do |conflicting_package, old_version, new_version| next old_version if old_version == new_version odie "Conflicting versions found for the `#{conflicting_package}` resource: #{old_version}, #{new_version}" end end # Remove extra packages that may be included in pipgrip output - exclude_list = %W[#{package_name.downcase} argparse pip setuptools wheel wsgiref] + exclude_list = %W[#{package_name.split("[").first.downcase} argparse pip setuptools wheel wsgiref] found_packages.delete_if { |package| exclude_list.include? package } new_resource_blocks = "" - found_packages.each do |package, package_version| + found_packages.sort.each do |package, package_version| if exclude_packages.include? package ohai "Excluding \"#{package}==#{package_version}\"" if !print_only && !silent next
true
Other
Homebrew
brew
b1d907291b7150b7a243c9a62ee22f3e9c0f2770.json
update man pages
docs/Manpage.md
@@ -1352,6 +1352,12 @@ Update versions for PyPI resource blocks in *`formula`*. Don't fail if *`formula`* is not a PyPI package. * `--version`: Use the specified *`version`* when finding resources for *`formula`*. If no version is specified, the current version for *`formula`* will be used. +* `--package-name`: + Use the specified *`package-name`* when finding resources for *`formula`*. If no package name is specified, it will be inferred from the formula's stable URL. +* `--extra-packages`: + Include these additional packages when finding resources. +* `--exclude-packages`: + Exclude these packages when finding resources. ### `update-test` [*`options`*]
true
Other
Homebrew
brew
b1d907291b7150b7a243c9a62ee22f3e9c0f2770.json
update man pages
manpages/brew.1
@@ -1884,6 +1884,18 @@ Don\'t fail if \fIformula\fR is not a PyPI package\. \fB\-\-version\fR Use the specified \fIversion\fR when finding resources for \fIformula\fR\. If no version is specified, the current version for \fIformula\fR will be used\. . +.TP +\fB\-\-package\-name\fR +Use the specified \fIpackage\-name\fR when finding resources for \fIformula\fR\. If no package name is specified, it will be inferred from the formula\'s stable URL\. +. +.TP +\fB\-\-extra\-packages\fR +Include these additional packages when finding resources\. +. +.TP +\fB\-\-exclude\-packages\fR +Exclude these packages when finding resources\. +. .SS "\fBupdate\-test\fR [\fIoptions\fR]" Run a test of \fBbrew update\fR with a new repository clone\. If no options are passed, use \fBorigin/master\fR as the start commit\. .
true
Other
Homebrew
brew
c32415529532369c6fffdd34c95da1ee21546f87.json
Add debug information for empty BOM error.
Library/Homebrew/unpack_strategy/dmg.rb
@@ -91,18 +91,25 @@ def extract_to_dir(unpack_dir, basename:, verbose:) Tempfile.open(["", ".bom"]) do |bomfile| bomfile.close + bom = path.bom + Tempfile.open(["", ".list"]) do |filelist| - filelist.puts(path.bom) + filelist.puts(bom) filelist.close system_command! "mkbom", args: ["-s", "-i", filelist.path, "--", bomfile.path], verbose: verbose end - system_command! "ditto", - args: ["--bom", bomfile.path, "--", path, unpack_dir], - verbose: verbose + result = system_command! "ditto", + args: ["--bom", bomfile.path, "--", path, unpack_dir], + verbose: verbose + + odebug "BOM contents:", bom + if result.stderr.include?("contains no files, nothing copied") + odebug "Directory contents:", Pathname.glob(path/"**/*", File::FNM_DOTMATCH).map(&:to_s).join("\n") + end FileUtils.chmod "u+w", Pathname.glob(unpack_dir/"**/*", File::FNM_DOTMATCH).reject(&:symlink?) end
false
Other
Homebrew
brew
5d0a4d58c28420864aa248114a54572c694e474d.json
formula_auditor: add cairomm@1.14 to allowlist
Library/Homebrew/formula_auditor.rb
@@ -372,6 +372,7 @@ def audit_postgresql openssl@1.1 python@3.8 python@3.9 + cairomm@1.14 ].freeze def audit_versioned_keg_only
false
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/extend/os/mac/extend/ENV/std.rb
@@ -7,7 +7,7 @@ module Stdenv undef homebrew_extra_pkg_config_paths, x11 def homebrew_extra_pkg_config_paths - ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] + ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"] end def x11
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -34,7 +34,7 @@ def homebrew_extra_paths # @private def homebrew_extra_pkg_config_paths paths = \ - ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] + ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"] paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11? paths end
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/os/mac.rb
@@ -25,7 +25,7 @@ module Mac # This can be compared to numerics, strings, or symbols # using the standard Ruby Comparable methods. def version - @version ||= Version.new(full_version.to_s[/^\d+\.\d+/]) + @version ||= Version.from_symbol(full_version.to_sym) end # This can be compared to numerics, strings, or symbols @@ -39,9 +39,16 @@ def full_version=(version) @version = nil end + sig { returns(::Version) } def latest_sdk_version # TODO: bump version when new Xcode macOS SDK is released - Version.new "11.0" + ::Version.new("11.0") + end + private :latest_sdk_version + + sig { returns(::Version) } + def sdk_version + full_version.major_minor end def outdated_release? @@ -55,7 +62,7 @@ def prerelease? # TODO: bump version when new macOS is released or announced # and also update references in docs/Installation.md and # https://github.com/Homebrew/install/blob/HEAD/install.sh - version >= "12.0" + version >= "12" end def languages
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/os/mac/version.rb
@@ -1,6 +1,7 @@ # typed: true # frozen_string_literal: true +require "exceptions" require "hardware" require "version" @@ -10,8 +11,10 @@ module Mac # # @api private class Version < ::Version + extend T::Sig + SYMBOLS = { - big_sur: "11.0", + big_sur: "11", catalina: "10.15", mojave: "10.14", high_sierra: "10.13", @@ -20,35 +23,44 @@ class Version < ::Version yosemite: "10.10", }.freeze + sig { params(sym: Symbol).returns(T.attached_class) } def self.from_symbol(sym) str = SYMBOLS.fetch(sym) { raise MacOSVersionError, sym } new(str) end + sig { params(value: T.nilable(String)).void } def initialize(value) - super(value) + raise MacOSVersionError, value unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(value) - raise MacOSVersionError, value unless value.match?(/\A1\d+(?:\.\d+){0,2}\Z/) + super(value) @comparison_cache = {} end def <=>(other) @comparison_cache.fetch(other) do - v = SYMBOLS.fetch(other) { other.to_s } - @comparison_cache[other] = super(::Version.new(v)) + if SYMBOLS.key?(other) && to_sym == other + 0 + else + v = SYMBOLS.fetch(other) { other.to_s } + @comparison_cache[other] = super(::Version.new(v)) + end end end + sig { returns(Symbol) } def to_sym - SYMBOLS.invert.fetch(@version, :dunno) + @to_sym ||= SYMBOLS.invert.fetch((major >= 11 ? major : major_minor).to_s, :dunno) end + sig { returns(String) } def pretty_name - to_sym.to_s.split("_").map(&:capitalize).join(" ") + @pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze end # For {OS::Mac::Version} compatibility. + sig { returns(T::Boolean) } def requires_nehalem_cpu? unless Hardware::CPU.intel? raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/os/mac/xcode.rb
@@ -22,7 +22,7 @@ module Xcode def latest_version latest_stable = "12.2" case MacOS.version - when /^11\./ then latest_stable + when "11" then latest_stable when "10.15" then "12.2" when "10.14" then "11.3.1" when "10.13" then "10.1" @@ -45,7 +45,7 @@ def latest_version sig { returns(String) } def minimum_version case MacOS.version - when /^11\./ then "12.2" + when "11" then "12.2" when "10.15" then "11.0" when "10.14" then "10.2" when "10.13" then "9.0" @@ -54,28 +54,33 @@ def minimum_version end end + sig { returns(T::Boolean) } def below_minimum_version? return false unless installed? version < minimum_version end + sig { returns(T::Boolean) } def latest_sdk_version? - OS::Mac.version >= OS::Mac.latest_sdk_version + OS::Mac.full_version >= OS::Mac.latest_sdk_version end + sig { returns(T::Boolean) } def needs_clt_installed? return false if latest_sdk_version? without_clt? end + sig { returns(T::Boolean) } def outdated? return false unless installed? version < latest_version end + sig { returns(T::Boolean) } def without_clt? !MacOS::CLT.installed? end @@ -275,7 +280,7 @@ def update_instructions sig { returns(String) } def latest_clang_version case MacOS.version - when /^11\./, "10.15" then "1200.0.32.27" + when "11", "10.15" then "1200.0.32.27" when "10.14" then "1100.0.33.17" when "10.13" then "1000.10.44.2" when "10.12" then "900.0.39.2" @@ -291,7 +296,7 @@ def latest_clang_version sig { returns(String) } def minimum_version case MacOS.version - when /^11\./ then "12.0.0" + when "11" then "12.0.0" when "10.15" then "11.0.0" when "10.14" then "10.0.0" when "10.13" then "9.0.0"
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/tap_constants.rb
@@ -6,7 +6,7 @@ # Match taps' casks, e.g. `someuser/sometap/somecask` HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$}.freeze # Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap` -HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze +HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze # Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula` HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze # Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask`
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/test/os/mac/diagnostic_spec.rb
@@ -6,25 +6,32 @@ describe Homebrew::Diagnostic::Checks do specify "#check_for_unsupported_macos" do ENV.delete("HOMEBREW_DEVELOPER") - allow(OS::Mac).to receive(:version).and_return(OS::Mac::Version.new("10.14")) + + macos_version = OS::Mac::Version.new("10.14") + allow(OS::Mac).to receive(:version).and_return(macos_version) + allow(OS::Mac).to receive(:full_version).and_return(macos_version) allow(OS::Mac).to receive(:prerelease?).and_return(true) expect(subject.check_for_unsupported_macos) .to match("We do not provide support for this pre-release version.") end specify "#check_if_xcode_needs_clt_installed" do - allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.11")) - allow(MacOS::Xcode).to receive(:installed?).and_return(true) - allow(MacOS::Xcode).to receive(:version).and_return("8.0") - allow(MacOS::Xcode).to receive(:without_clt?).and_return(true) + macos_version = OS::Mac::Version.new("10.11") + allow(OS::Mac).to receive(:version).and_return(macos_version) + allow(OS::Mac).to receive(:full_version).and_return(macos_version) + allow(OS::Mac::Xcode).to receive(:installed?).and_return(true) + allow(OS::Mac::Xcode).to receive(:version).and_return("8.0") + allow(OS::Mac::Xcode).to receive(:without_clt?).and_return(true) expect(subject.check_if_xcode_needs_clt_installed) .to match("Xcode alone is not sufficient on El Capitan") end specify "#check_ruby_version" do - allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.12")) + macos_version = OS::Mac::Version.new("10.12") + allow(OS::Mac).to receive(:version).and_return(macos_version) + allow(OS::Mac).to receive(:full_version).and_return(macos_version) stub_const("RUBY_VERSION", "1.8.6") expect(subject.check_ruby_version)
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/test/os/mac/pkgconfig_spec.rb
@@ -15,7 +15,7 @@ # For indeterminable cases, consult https://opensource.apple.com for the version used. describe "pkg-config" do def pc_version(library) - path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc" + path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.sdk_version}/#{library}.pc" version = File.foreach(path) .lazy .grep(/^Version:\s*?(.+)$/) { Regexp.last_match(1) }
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/test/os/mac/version_spec.rb
@@ -5,7 +5,9 @@ require "os/mac/version" describe OS::Mac::Version do - subject(:version) { described_class.new("10.14") } + let(:version) { described_class.new("10.14") } + let(:big_sur_major) { described_class.new("11.0") } + let(:big_sur_update) { described_class.new("11.1") } specify "comparison with Symbol" do expect(version).to be > :high_sierra @@ -38,6 +40,22 @@ expect(version).to be < Version.create("10.15") end + context "after Big Sur" do + specify "comparison with :big_sur" do + expect(big_sur_major).to eq :big_sur + expect(big_sur_major).to be <= :big_sur + expect(big_sur_major).to be >= :big_sur + expect(big_sur_major).not_to be > :big_sur + expect(big_sur_major).not_to be < :big_sur + + expect(big_sur_update).to eq :big_sur + expect(big_sur_update).to be <= :big_sur + expect(big_sur_update).to be >= :big_sur + expect(big_sur_update).not_to be > :big_sur + expect(big_sur_update).not_to be < :big_sur + end + end + describe "#new" do it "raises an error if the version is not a valid macOS version" do expect {
true
Other
Homebrew
brew
8598b1186a32c98e7ed292880ef135182825c42e.json
Handle macOS versions >= 11.1 correctly.
Library/Homebrew/utils/analytics.rb
@@ -1,6 +1,7 @@ # typed: false # frozen_string_literal: true +require "context" require "erb" module Utils
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/context.rb
@@ -34,15 +34,15 @@ def initialize(debug: nil, quiet: nil, verbose: nil) end def debug? - @debug + @debug == true end def quiet? - @quiet + @quiet == true end def verbose? - @verbose + @verbose == true end end
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/sorbet/plugins/using.rb
@@ -3,7 +3,8 @@ source = ARGV[5] -/\busing +Magic\b/.match(source) do |_| +case source[/\Ausing\s+(.*)\Z/, 1] +when "Magic" puts <<-RUBY # typed: strict @@ -18,4 +19,13 @@ def file_type; end def zipinfo; end end RUBY +when "HashValidator" + puts <<-RUBY + # typed: strict + + class ::Hash + sig { params(valid_keys: T.untyped).void } + def assert_valid_keys!(*valid_keys); end + end + RUBY end
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -28559,6 +28559,7 @@ class Socket IPV6_PATHMTU = ::T.let(nil, ::T.untyped) IPV6_RECVPATHMTU = ::T.let(nil, ::T.untyped) IPV6_USE_MIN_MTU = ::T.let(nil, ::T.untyped) + IP_DONTFRAG = ::T.let(nil, ::T.untyped) IP_PORTRANGE = ::T.let(nil, ::T.untyped) IP_RECVDSTADDR = ::T.let(nil, ::T.untyped) IP_RECVIF = ::T.let(nil, ::T.untyped) @@ -28650,6 +28651,7 @@ module Socket::Constants IPV6_PATHMTU = ::T.let(nil, ::T.untyped) IPV6_RECVPATHMTU = ::T.let(nil, ::T.untyped) IPV6_USE_MIN_MTU = ::T.let(nil, ::T.untyped) + IP_DONTFRAG = ::T.let(nil, ::T.untyped) IP_PORTRANGE = ::T.let(nil, ::T.untyped) IP_RECVDSTADDR = ::T.let(nil, ::T.untyped) IP_RECVIF = ::T.let(nil, ::T.untyped) @@ -29210,6 +29212,11 @@ end class SynchronizedDelegator end +class SystemCommand::Result + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class SystemCommand extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/sorbet/triggers.yml
@@ -2,6 +2,6 @@ ruby_extra_args: - --disable-gems triggers: - using: sorbet/plugins/unpack_strategy_magic.rb + using: sorbet/plugins/using.rb attr_predicate: sorbet/plugins/attr_predicate.rb delegate: sorbet/plugins/delegate.rb
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/system_command.rb
@@ -9,22 +9,23 @@ require "extend/io" require "extend/predicable" require "extend/hash_validator" -using HashValidator # Class for running sub-processes and capturing their output and exit status. # # @api private class SystemCommand extend T::Sig + using HashValidator + # Helper functions for calling {SystemCommand.run}. module Mixin def system_command(*args) - SystemCommand.run(*args) + T.unsafe(SystemCommand).run(*args) end def system_command!(*args) - SystemCommand.run!(*args) + T.unsafe(SystemCommand).run!(*args) end end @@ -34,11 +35,11 @@ def system_command!(*args) attr_reader :pid def self.run(executable, **options) - new(executable, **options).run! + T.unsafe(self).new(executable, **options).run! end def self.run!(command, **options) - run(command, **options, must_succeed: true) + T.unsafe(self).run(command, **options, must_succeed: true) end sig { returns(SystemCommand::Result) } @@ -63,45 +64,61 @@ def run! result end + sig do + params( + executable: T.any(String, Pathname), + args: T::Array[T.any(String, Integer, Float, URI::Generic)], + sudo: T::Boolean, + env: T::Hash[String, String], + input: T.any(String, T::Array[String]), + must_succeed: T::Boolean, + print_stdout: T::Boolean, + print_stderr: T::Boolean, + verbose: T::Boolean, + secrets: T::Array[String], + chdir: T.any(String, Pathname), + ).void + end def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succeed: false, - print_stdout: false, print_stderr: true, verbose: false, secrets: [], **options) + print_stdout: false, print_stderr: true, verbose: false, secrets: [], chdir: T.unsafe(nil)) require "extend/ENV" @executable = executable @args = args @sudo = sudo + env.each_key do |name| + next if /^[\w&&\D]\w*$/.match?(name) + + raise ArgumentError, "Invalid variable name: '#{name}'" + end + @env = env @input = Array(input) + @must_succeed = must_succeed @print_stdout = print_stdout @print_stderr = print_stderr @verbose = verbose @secrets = (Array(secrets) + ENV.sensitive_environment.values).uniq - @must_succeed = must_succeed - options.assert_valid_keys!(:chdir) - @options = options - @env = env - - @env.each_key do |name| - next if /^[\w&&\D]\w*$/.match?(name) - - raise ArgumentError, "Invalid variable name: '#{name}'" - end + @chdir = chdir end + sig { returns(T::Array[String]) } def command [*sudo_prefix, *env_args, executable.to_s, *expanded_args] end private - attr_reader :executable, :args, :input, :options, :env + attr_reader :executable, :args, :input, :chdir, :env attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed? + sig { returns(T::Boolean) } def verbose? return super if @verbose.nil? @verbose end + sig { returns(T::Array[String]) } def env_args set_variables = env.compact.map do |name, value| sanitized_name = Shellwords.escape(name) @@ -114,18 +131,20 @@ def env_args ["/usr/bin/env", *set_variables] end + sig { returns(T::Array[String]) } def sudo_prefix return [] unless sudo? askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : [] ["/usr/bin/sudo", *askpass_flags, "-E", "--"] end + sig { returns(T::Array[String]) } def expanded_args @expanded_args ||= args.map do |arg| if arg.respond_to?(:to_path) File.absolute_path(arg) - elsif arg.is_a?(Integer) || arg.is_a?(Float) || arg.is_a?(URI) + elsif arg.is_a?(Integer) || arg.is_a?(Float) || arg.is_a?(URI::Generic) arg.to_s else arg.to_str @@ -137,7 +156,7 @@ def each_output_line(&b) executable, *args = command raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = - Open3.popen3(env, [executable, executable], *args, **options) + T.unsafe(Open3).popen3(env, [executable, executable], *args, **{ chdir: chdir }.compact) @pid = raw_wait_thr.pid write_input_to(raw_stdin) @@ -158,7 +177,7 @@ def each_line_from(sources) loop do readable_sources, = IO.select(sources) - readable_sources = readable_sources.reject(&:eof?) + readable_sources = T.must(readable_sources).reject(&:eof?) break if readable_sources.empty? @@ -176,10 +195,20 @@ def each_line_from(sources) # Result containing the output and exit status of a finished sub-process. class Result + extend T::Sig + include Context attr_accessor :command, :status, :exit_status + sig do + params( + command: T::Array[String], + output: T::Array[[Symbol, String]], + status: Process::Status, + secrets: T::Array[String], + ).void + end def initialize(command, output, status, secrets:) @command = command @output = output @@ -188,57 +217,65 @@ def initialize(command, output, status, secrets:) @secrets = secrets end + sig { void } def assert_success! return if @status.success? raise ErrorDuringExecution.new(command, status: @status, output: @output, secrets: @secrets) end + sig { returns(String) } def stdout @stdout ||= @output.select { |type,| type == :stdout } .map { |_, line| line } .join end + sig { returns(String) } def stderr @stderr ||= @output.select { |type,| type == :stderr } .map { |_, line| line } .join end + sig { returns(String) } def merged_output @merged_output ||= @output.map { |_, line| line } .join end + sig { returns(T::Boolean) } def success? return false if @exit_status.nil? @exit_status.zero? end + sig { returns([String, String, Process::Status]) } def to_ary [stdout, stderr, status] end + sig { returns(T.nilable(T.any(Array, Hash))) } def plist @plist ||= begin output = stdout - if /\A(?<garbage>.*?)<\?\s*xml/m =~ output - output = output.sub(/\A#{Regexp.escape(garbage)}/m, "") - warn_plist_garbage(garbage) + output = output.sub(/\A(.*?)(\s*<\?\s*xml)/m) do + warn_plist_garbage(T.must(Regexp.last_match(1))) + Regexp.last_match(2) end - if %r{<\s*/\s*plist\s*>(?<garbage>.*?)\Z}m =~ output - output = output.sub(/#{Regexp.escape(garbage)}\Z/, "") - warn_plist_garbage(garbage) + output = output.sub(%r{(<\s*/\s*plist\s*>\s*)(.*?)\Z}m) do + warn_plist_garbage(T.must(Regexp.last_match(2))) + Regexp.last_match(1) end Plist.parse_xml(output) end end + sig { params(garbage: String).void } def warn_plist_garbage(garbage) return unless verbose? return unless garbage.match?(/\S/)
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb
@@ -8,7 +8,7 @@ let(:artifact_dsl_key) { described_class.dsl_key } let(:artifact) { cask.artifacts.find { |a| a.is_a?(described_class) } } - let(:fake_system_command) { FakeSystemCommand } + let(:fake_system_command) { class_double(SystemCommand) } context "using :launchctl" do let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-launchctl")) } @@ -31,41 +31,37 @@ end it "works when job is owned by user" do - FakeSystemCommand.stubs_command( - launchctl_list_cmd, - service_info, - ) - - FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - unknown_response, - ) + allow(fake_system_command).to receive(:run) + .with("/bin/launchctl", args: ["list", "my.fancy.package.service"], print_stderr: false, sudo: false) + .and_return(instance_double(SystemCommand::Result, stdout: service_info)) + allow(fake_system_command).to receive(:run) + .with("/bin/launchctl", args: ["list", "my.fancy.package.service"], print_stderr: false, sudo: true) + .and_return(instance_double(SystemCommand::Result, stdout: unknown_response)) - FakeSystemCommand.expects_command(launchctl_remove_cmd) + expect(fake_system_command).to receive(:run!) + .with("/bin/launchctl", args: ["remove", "my.fancy.package.service"], sudo: false) + .and_return(instance_double(SystemCommand::Result)) subject.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) end it "works when job is owned by system" do - FakeSystemCommand.stubs_command( - launchctl_list_cmd, - unknown_response, - ) + allow(fake_system_command).to receive(:run) + .with("/bin/launchctl", args: ["list", "my.fancy.package.service"], print_stderr: false, sudo: false) + .and_return(instance_double(SystemCommand::Result, stdout: unknown_response)) + allow(fake_system_command).to receive(:run) + .with("/bin/launchctl", args: ["list", "my.fancy.package.service"], print_stderr: false, sudo: true) + .and_return(instance_double(SystemCommand::Result, stdout: service_info)) - FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - service_info, - ) - - FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) + expect(fake_system_command).to receive(:run!) + .with("/bin/launchctl", args: ["remove", "my.fancy.package.service"], sudo: true) + .and_return(instance_double(SystemCommand::Result)) subject.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) end end context "using :pkgutil" do - let(:fake_system_command) { class_double(SystemCommand) } - let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-pkgutil")) } let(:main_pkg_id) { "my.fancy.package.main" }
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/dsl/postflight_spec.rb
@@ -6,7 +6,8 @@ describe Cask::DSL::Postflight, :cask do let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) } - let(:dsl) { described_class.new(cask, FakeSystemCommand) } + let(:fake_system_command) { class_double(SystemCommand) } + let(:dsl) { described_class.new(cask, fake_system_command) } it_behaves_like Cask::DSL::Base
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/dsl/preflight_spec.rb
@@ -6,7 +6,8 @@ describe Cask::DSL::Preflight, :cask do let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) } - let(:dsl) { described_class.new(cask, FakeSystemCommand) } + let(:fake_system_command) { class_double(SystemCommand) } + let(:dsl) { described_class.new(cask, fake_system_command) } it_behaves_like Cask::DSL::Base
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/dsl/shared_examples/staged.rb
@@ -4,8 +4,8 @@ require "cask/staged" shared_examples Cask::Staged do - let(:existing_path) { Pathname.new("/path/to/file/that/exists") } - let(:non_existent_path) { Pathname.new("/path/to/file/that/does/not/exist") } + let(:existing_path) { Pathname("/path/to/file/that/exists") } + let(:non_existent_path) { Pathname("/path/to/file/that/does/not/exist") } before do allow(existing_path).to receive(:exist?).and_return(true) @@ -17,9 +17,8 @@ end it "can run system commands with list-form arguments" do - FakeSystemCommand.expects_command( - ["echo", "homebrew-cask", "rocks!"], - ) + expect(fake_system_command).to receive(:run!) + .with("echo", args: ["homebrew-cask", "rocks!"]) staged.system_command("echo", args: ["homebrew-cask", "rocks!"]) end @@ -28,9 +27,8 @@ fake_pathname = existing_path allow(staged).to receive(:Pathname).and_return(fake_pathname) - FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname], - ) + expect(fake_system_command).to receive(:run!) + .with("/bin/chmod", args: ["-R", "--", "777", fake_pathname], sudo: false) staged.set_permissions(fake_pathname.to_s, "777") end @@ -39,9 +37,8 @@ fake_pathname = existing_path allow(staged).to receive(:Pathname).and_return(fake_pathname) - FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname], - ) + expect(fake_system_command).to receive(:run!) + .with("/bin/chmod", args: ["-R", "--", "777", fake_pathname, fake_pathname], sudo: false) staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") end @@ -58,9 +55,8 @@ allow(User).to receive(:current).and_return(User.new("fake_user")) allow(staged).to receive(:Pathname).and_return(fake_pathname) - FakeSystemCommand.expects_command( - sudo("/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname), - ) + expect(fake_system_command).to receive(:run!) + .with("/usr/sbin/chown", args: ["-R", "--", "fake_user:staff", fake_pathname], sudo: true) staged.set_ownership(fake_pathname.to_s) end @@ -71,9 +67,8 @@ allow(User).to receive(:current).and_return(User.new("fake_user")) allow(staged).to receive(:Pathname).and_return(fake_pathname) - FakeSystemCommand.expects_command( - sudo("/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname), - ) + expect(fake_system_command).to receive(:run!) + .with("/usr/sbin/chown", args: ["-R", "--", "fake_user:staff", fake_pathname, fake_pathname], sudo: true) staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) end @@ -83,9 +78,8 @@ allow(staged).to receive(:Pathname).and_return(fake_pathname) - FakeSystemCommand.expects_command( - sudo("/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname), - ) + expect(fake_system_command).to receive(:run!) + .with("/usr/sbin/chown", args: ["-R", "--", "other_user:other_group", fake_pathname], sudo: true) staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group") end
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/dsl/uninstall_postflight_spec.rb
@@ -5,7 +5,7 @@ describe Cask::DSL::UninstallPostflight, :cask do let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) } - let(:dsl) { described_class.new(cask, FakeSystemCommand) } + let(:dsl) { described_class.new(cask, class_double(SystemCommand)) } it_behaves_like Cask::DSL::Base end
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/dsl/uninstall_preflight_spec.rb
@@ -6,7 +6,8 @@ describe Cask::DSL::UninstallPreflight, :cask do let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) } - let(:dsl) { described_class.new(cask, FakeSystemCommand) } + let(:fake_system_command) { class_double(SystemCommand) } + let(:dsl) { described_class.new(cask, fake_system_command) } it_behaves_like Cask::DSL::Base
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/cask/pkg_spec.rb
@@ -153,8 +153,12 @@ "/usr/sbin/pkgutil", args: ["--pkg-info-plist", pkg_id], ).and_return( - SystemCommand::Result.new(nil, [[:stdout, pkg_info_plist]], instance_double(Process::Status, exitstatus: 0), - secrets: []), + SystemCommand::Result.new( + ["/usr/sbin/pkgutil", "--pkg-info-plist", pkg_id], + [[:stdout, pkg_info_plist]], + instance_double(Process::Status, exitstatus: 0), + secrets: [], + ), ) info = pkg.info
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/support/helper/cask/fake_system_command.rb
@@ -1,74 +0,0 @@ -# typed: true -# frozen_string_literal: true - -def sudo(*args) - ["/usr/bin/sudo", "-E", "--"] + args.flatten -end - -class FakeSystemCommand - def self.responses - @responses ||= {} - end - - def self.expectations - @expectations ||= {} - end - - def self.system_calls - @system_calls ||= Hash.new(0) - end - - def self.clear - @responses = nil - @expectations = nil - @system_calls = nil - end - - def self.stubs_command(command, response = "") - command = command.map(&:to_s) - responses[command] = response - end - - def self.expects_command(command, response = "", times = 1) - command = command.map(&:to_s) - stubs_command(command, response) - expectations[command] = times - end - - def self.verify_expectations! - expectations.each do |command, times| - unless system_calls[command] == times - raise("expected #{command.inspect} to be run #{times} times, but got #{system_calls[command]}") - end - end - end - - def self.run(command_string, options = {}) - command = SystemCommand.new(command_string, options).command - puts command - unless responses.key?(command) - raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}") - end - - system_calls[command] += 1 - - response = responses[command] - if response.respond_to?(:call) - response.call(command_string, options) - else - SystemCommand::Result.new(command, [[:stdout, response]], OpenStruct.new(exitstatus: 0), secrets: []) - end - end - - def self.run!(command, options = {}) - run(command, options.merge(must_succeed: true)) - end -end - -RSpec.configure do |config| - config.after do - FakeSystemCommand.verify_expectations! - ensure - FakeSystemCommand.clear - end -end
true
Other
Homebrew
brew
d5b184d17a9ffcfd5ad1c7c6780633a53e3f8086.json
Add types for `SystemCommand`.
Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
@@ -4,7 +4,6 @@ require "cask/config" require "cask/cache" -require "test/support/helper/cask/fake_system_command" require "test/support/helper/cask/install_helper" require "test/support/helper/cask/never_sudo_system_command"
true
Other
Homebrew
brew
45ed865008409dcb1bb8d54e4b6c61684d9e5c96.json
bump-cask-pr: run auto-update beforehand
Library/Homebrew/brew.sh
@@ -160,7 +160,7 @@ update-preinstall() { fi if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || - "$HOMEBREW_COMMAND" = "bump-formula-pr" || + "$HOMEBREW_COMMAND" = "bump-formula-pr" || "$HOMEBREW_COMMAND" = "bump-cask-pr" || "$HOMEBREW_COMMAND" = "bundle" || "$HOMEBREW_COMMAND" = "tap" && $HOMEBREW_ARG_COUNT -gt 1 || "$HOMEBREW_CASK_COMMAND" = "install" || "$HOMEBREW_CASK_COMMAND" = "upgrade" ]]
false
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/env_config.rb
@@ -351,6 +351,7 @@ def env_method_name(env, hash) end # Needs a custom implementation. + sig { returns(String) } def make_jobs jobs = ENV["HOMEBREW_MAKE_JOBS"].to_i return jobs.to_s if jobs.positive?
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: strict # frozen_string_literal: true require "hardware" @@ -7,11 +7,22 @@ require "extend/ENV/std" require "extend/ENV/super" -def superenv?(env) - env != "std" && Superenv.bin +module Kernel + extend T::Sig + + sig { params(env: T.nilable(String)).returns(T::Boolean) } + def superenv?(env) + return false if env == "std" + + !Superenv.bin.nil? + end + private :superenv? end module EnvActivation + extend T::Sig + + sig { params(env: T.nilable(String)).void } def activate_extensions!(env: nil) if superenv?(env) extend(Superenv) @@ -20,25 +31,41 @@ def activate_extensions!(env: nil) end end - def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil) + sig do + params( + env: T.nilable(String), + cc: T.nilable(String), + build_bottle: T.nilable(T::Boolean), + bottle_arch: T.nilable(String), + _block: T.proc.returns(T.untyped), + ).returns(T.untyped) + end + def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, &_block) old_env = to_hash.dup tmp_env = to_hash.dup.extend(EnvActivation) - tmp_env.activate_extensions!(env: env) - tmp_env.setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch) + T.cast(tmp_env, EnvActivation).activate_extensions!(env: env) + T.cast(tmp_env, T.any(Superenv, Stdenv)) + .setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch) replace(tmp_env) - yield - ensure - replace(old_env) + + begin + yield + ensure + replace(old_env) + end end + sig { params(key: T.any(String, Symbol)).returns(T::Boolean) } def sensitive?(key) - /(cookie|key|token|password)/i =~ key + key.match?(/(cookie|key|token|password)/i) end + sig { returns(T::Hash[String, String]) } def sensitive_environment select { |key, _| sensitive?(key) } end + sig { void } def clear_sensitive_environment! each_key { |key| delete key if sensitive?(key) } end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV.rbi
@@ -0,0 +1,49 @@ +# typed: strict + +module EnvMethods + include Kernel + + sig { params(key: String).returns(T::Boolean) } + def key?(key); end + + sig { params(key: String).returns(T.nilable(String)) } + def [](key); end + + sig { params(key: String).returns(String) } + def fetch(key); end + + sig { params(key: String, value: T.nilable(T.any(String, PATH))).returns(T.nilable(String)) } + def []=(key, value); end + + sig { params(block: T.proc.params(arg0: [String, String]).returns(T::Boolean)).returns(T::Hash[String, String]) } + def select(&block); end + + sig { params(block: T.proc.params(arg0: String).void).void } + def each_key(&block); end + + sig { params(key: String).returns(T.nilable(String)) } + def delete(key); end + + sig do + params(other: T.any(T::Hash[String, String], Sorbet::Private::Static::ENVClass)) + .returns(Sorbet::Private::Static::ENVClass) + end + def replace(other); end + + sig { returns(T::Hash[String, String]) } + def to_hash; end +end + +module EnvActivation + include EnvMethods +end + +class Sorbet + module Private + module Static + class ENVClass + include EnvActivation + end + end + end +end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV/shared.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "compilers" @@ -11,13 +11,16 @@ # @see Stdenv # @see https://www.rubydoc.info/stdlib/Env Ruby's ENV API module SharedEnvExtension + extend T::Sig + include CompilerConstants - # @private CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS].freeze - # @private + private_constant :CC_FLAG_VARS + FC_FLAG_VARS = %w[FCFLAGS FFLAGS].freeze - # @private + private_constant :FC_FLAG_VARS + SANITIZED_VARS = %w[ CDPATH CLICOLOR_FORCE CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH @@ -28,66 +31,79 @@ module SharedEnvExtension GOBIN GOPATH GOROOT PERL_MB_OPT PERL_MM_OPT LIBRARY_PATH LD_LIBRARY_PATH LD_PRELOAD LD_RUN_PATH ].freeze + private_constant :SANITIZED_VARS - # @private + sig do + params( + formula: T.nilable(Formula), + cc: T.nilable(String), + build_bottle: T.nilable(T::Boolean), + bottle_arch: T.nilable(T::Boolean), + ).void + end def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil) @formula = formula @cc = cc @build_bottle = build_bottle @bottle_arch = bottle_arch reset end + private :setup_build_environment - # @private + sig { void } def reset SANITIZED_VARS.each { |k| delete(k) } end + private :reset + sig { returns(T::Hash[String, String]) } def remove_cc_etc keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS] - removed = Hash[*keys.flat_map { |key| [key, self[key]] }] - keys.each do |key| - delete(key) - end - removed + keys.map { |key| [key, delete(key)] }.to_h end + sig { params(newflags: String).void } def append_to_cflags(newflags) append(CC_FLAG_VARS, newflags) end + sig { params(val: T.any(Regexp, String)).void } def remove_from_cflags(val) remove CC_FLAG_VARS, val end + sig { params(value: String).void } def append_to_cccfg(value) append("HOMEBREW_CCCFG", value, "") end + sig { params(keys: T.any(String, T::Array[String]), value: T.untyped, separator: String).void } def append(keys, value, separator = " ") value = value.to_s Array(keys).each do |key| - old = self[key] - if old.nil? || old.empty? - self[key] = value + old_value = self[key] + self[key] = if old_value.nil? || old_value.empty? + value else - self[key] += separator + value + old_value + separator + value end end end + sig { params(keys: T.any(String, T::Array[String]), value: T.untyped, separator: String).void } def prepend(keys, value, separator = " ") value = value.to_s Array(keys).each do |key| - old = self[key] - self[key] = if old.nil? || old.empty? + old_value = self[key] + self[key] = if old_value.nil? || old_value.empty? value else - value + separator + old + value + separator + old_value end end end + sig { params(key: String, path: String).void } def append_path(key, path) self[key] = PATH.new(self[key]).append(path) end @@ -99,61 +115,78 @@ def append_path(key, path) # Prepending a system path such as /usr/bin is a no-op so that requirements # don't accidentally override superenv shims or formulae's `bin` directories. # <pre>ENV.prepend_path "PATH", which("emacs").dirname</pre> + sig { params(key: String, path: String).void } def prepend_path(key, path) return if %w[/usr/bin /bin /usr/sbin /sbin].include? path.to_s self[key] = PATH.new(self[key]).prepend(path) end + sig { params(key: String, path: T.any(String, Pathname)).void } def prepend_create_path(key, path) - path = Pathname.new(path) unless path.is_a? Pathname + path = Pathname(path) path.mkpath prepend_path key, path end + sig { params(keys: T.any(String, T::Array[String]), value: T.untyped).void } def remove(keys, value) return if value.nil? Array(keys).each do |key| - next unless self[key] + old_value = self[key] + next if old_value.nil? - self[key] = self[key].sub(value, "") - delete(key) if self[key].empty? + new_value = old_value.sub(value, "") + if new_value.empty? + delete(key) + else + self[key] = new_value + end end end + sig { returns(T.nilable(String)) } def cc self["CC"] end + sig { returns(T.nilable(String)) } def cxx self["CXX"] end + sig { returns(T.nilable(String)) } def cflags self["CFLAGS"] end + sig { returns(T.nilable(String)) } def cxxflags self["CXXFLAGS"] end + sig { returns(T.nilable(String)) } def cppflags self["CPPFLAGS"] end + sig { returns(T.nilable(String)) } def ldflags self["LDFLAGS"] end + sig { returns(T.nilable(String)) } def fc self["FC"] end + sig { returns(T.nilable(String)) } def fflags self["FFLAGS"] end + sig { returns(T.nilable(String)) } def fcflags self["FCFLAGS"] end @@ -164,8 +197,7 @@ def fcflags # # modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go: # ENV.append_to_cflags "-I ./missing/includes" # end</pre> - # - # @return [Symbol] + sig { returns(T.any(Symbol, String)) } def compiler @compiler ||= if (cc = @cc) warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP) @@ -189,27 +221,31 @@ def compiler end end - # @private + sig { returns(T.any(String, Pathname)) } def determine_cc COMPILER_SYMBOL_MAP.invert.fetch(compiler, compiler) end + private :determine_cc COMPILERS.each do |compiler| define_method(compiler) do @compiler = compiler - self.cc = determine_cc - self.cxx = determine_cxx + + send(:cc=, send(:determine_cc)) + send(:cxx=, send(:determine_cxx)) end end # Snow Leopard defines an NCURSES value the opposite of most distros. # @see https://bugs.python.org/issue6848 # Currently only used by aalib in core. + sig { void } def ncurses_define append "CPPFLAGS", "-DNCURSES_OPAQUE=0" end # @private + sig { void } def userpaths! path = PATH.new(self["PATH"]).select do |p| # put Superenv.bin and opt path at the first @@ -228,6 +264,7 @@ def userpaths! self["PATH"] = path end + sig { void } def fortran # Ignore repeated calls to this function as it will misleadingly warn about # building with an alternative Fortran compiler without optimization flags, @@ -260,6 +297,7 @@ def fortran end # @private + sig { returns(Symbol) } def effective_arch if @build_bottle && @bottle_arch @bottle_arch.to_sym @@ -269,6 +307,7 @@ def effective_arch end # @private + sig { params(name: String).returns(Formula) } def gcc_version_formula(name) version = name[GNU_GCC_REGEXP, 1] gcc_version_name = "gcc@#{version}" @@ -282,6 +321,7 @@ def gcc_version_formula(name) end # @private + sig { params(name: String).void } def warn_about_non_apple_gcc(name) begin gcc_formula = gcc_version_formula(name) @@ -299,30 +339,40 @@ def warn_about_non_apple_gcc(name) EOS end + sig { void } def permit_arch_flags; end # A no-op until we enable this by default again (which we may never do). + sig { void } def permit_weak_imports; end # @private + sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) } def compiler_any_clang?(cc = compiler) %w[clang llvm_clang].include?(cc.to_s) end private + sig { params(_flags: T::Array[String], _map: T::Hash[Symbol, String]).void } + def set_cpu_flags(_flags, _map = {}); end + + sig { params(val: T.any(String, Pathname)).returns(String) } def cc=(val) self["CC"] = self["OBJC"] = val.to_s end + sig { params(val: T.any(String, Pathname)).returns(String) } def cxx=(val) self["CXX"] = self["OBJCXX"] = val.to_s end + sig { returns(T.nilable(String)) } def homebrew_cc self["HOMEBREW_CC"] end + sig { params(value: String, source: String).returns(Symbol) } def fetch_compiler(value, source) COMPILER_SYMBOL_MAP.fetch(value) do |other| case other @@ -334,10 +384,9 @@ def fetch_compiler(value, source) end end + sig { void } def check_for_compiler_universal_support - return unless homebrew_cc.match?(GNU_GCC_REGEXP) - - raise "Non-Apple GCC can't build universal binaries" + raise "Non-Apple GCC can't build universal binaries" if homebrew_cc&.match?(GNU_GCC_REGEXP) end end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV/shared.rbi
@@ -0,0 +1,15 @@ +# typed: strict + +module SharedEnvExtension + include EnvMethods +end + +class Sorbet + module Private + module Static + class ENVClass + include SharedEnvExtension + end + end + end +end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV/std.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: strict # frozen_string_literal: true require "hardware" @@ -14,8 +14,16 @@ module Stdenv SAFE_CFLAGS_FLAGS = "-w -pipe" # @private - def setup_build_environment(**options) - super(**options) + sig do + params( + formula: T.nilable(Formula), + cc: T.nilable(String), + build_bottle: T.nilable(T::Boolean), + bottle_arch: T.nilable(T::Boolean), + ).void + end + def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil) + super self["HOMEBREW_ENV"] = "std" @@ -49,13 +57,14 @@ def setup_build_environment(**options) send(compiler) - return unless cc.match?(GNU_GCC_REGEXP) + return unless cc&.match?(GNU_GCC_REGEXP) gcc_formula = gcc_version_formula(cc) append_path "PATH", gcc_formula.opt_bin.to_s end alias generic_setup_build_environment setup_build_environment + sig { returns(T::Array[Pathname]) } def homebrew_extra_pkg_config_paths [] end @@ -73,10 +82,11 @@ def determine_pkg_config_libdir # Removes the MAKEFLAGS environment variable, causing make to use a single job. # This is useful for makefiles with race conditions. # When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion. - def deparallelize + sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) } + def deparallelize(&block) old = self["MAKEFLAGS"] remove "MAKEFLAGS", /-j\d+/ - if block_given? + if block begin yield ensure @@ -89,30 +99,33 @@ def deparallelize %w[O3 O2 O1 O0 Os].each do |opt| define_method opt do - remove_from_cflags(/-O./) - append_to_cflags "-#{opt}" + send(:remove_from_cflags, /-O./) + send(:append_to_cflags, "-#{opt}") end end - # @private + sig { returns(T.any(String, Pathname)) } def determine_cc s = super - DevelopmentTools.locate(s) || Pathname.new(s) + DevelopmentTools.locate(s) || Pathname(s) end + private :determine_cc - # @private + sig { returns(Pathname) } def determine_cxx - dir, base = determine_cc.split + dir, base = Pathname(determine_cc).split dir/base.to_s.sub("gcc", "g++").sub("clang", "clang++") end + private :determine_cxx GNU_GCC_VERSIONS.each do |n| define_method(:"gcc-#{n}") do super() - set_cpu_cflags + send(:set_cpu_cflags) end end + sig { void } def clang super() replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1') @@ -124,57 +137,66 @@ def clang set_cpu_cflags(map) end + sig { void } def m64 append_to_cflags "-m64" append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}" end + sig { void } def m32 append_to_cflags "-m32" append "LDFLAGS", "-arch #{Hardware::CPU.arch_32_bit}" end + sig { void } def universal_binary check_for_compiler_universal_support append_to_cflags Hardware::CPU.universal_archs.as_arch_flags append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags return if compiler_any_clang? - return unless Hardware.is_32_bit? + return unless Hardware::CPU.is_32_bit? # Can't mix "-march" for a 32-bit CPU with "-arch x86_64" replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0") end + sig { void } def cxx11 append "CXX", "-std=c++11" libcxx end + sig { void } def libcxx append "CXX", "-stdlib=libc++" if compiler == :clang end + sig { void } def libstdcxx append "CXX", "-stdlib=libstdc++" if compiler == :clang end # @private + sig { params(before: Regexp, after: String).void } def replace_in_cflags(before, after) CC_FLAG_VARS.each do |key| - self[key] = self[key].sub(before, after) if key?(key) + self[key] = fetch(key).sub(before, after) if key?(key) end end # Convenience method to set all C compiler flags in one shot. + sig { params(val: String).void } def define_cflags(val) CC_FLAG_VARS.each { |key| self[key] = val } end # Sets architecture-specific flags for every environment variable # given in the list `flags`. # @private + sig { params(flags: T::Array[String], map: T::Hash[Symbol, String]).void } def set_cpu_flags(flags, map = Hardware::CPU.optimization_flags) cflags =~ /(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=/ xarch = Regexp.last_match(1).to_s @@ -186,19 +208,23 @@ def set_cpu_flags(flags, map = Hardware::CPU.optimization_flags) append flags, map.fetch(effective_arch) end + sig { void } def x11; end # @private + sig { params(map: T::Hash[Symbol, String]).void } def set_cpu_cflags(map = Hardware::CPU.optimization_flags) # rubocop:disable Naming/AccessorMethodName set_cpu_flags(CC_FLAG_VARS, map) end + sig { returns(Integer) } def make_jobs Homebrew::EnvConfig.make_jobs.to_i end # This method does nothing in stdenv since there's no arg refurbishment # @private + sig { void } def refurbish_args; end end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/ENV/super.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "extend/ENV/shared" @@ -22,15 +22,18 @@ module Superenv # @private attr_accessor :keg_only_deps, :deps, :run_time_deps, :x11 + sig { params(base: Superenv).void } def self.extended(base) base.keg_only_deps = [] base.deps = [] base.run_time_deps = [] end # @private + sig { returns(T.nilable(Pathname)) } def self.bin; end + sig { void } def reset super # Configure scripts generated by autoconf 2.61 or later export as_nl, which @@ -39,8 +42,16 @@ def reset end # @private - def setup_build_environment(**options) - super(**options) + sig do + params( + formula: T.nilable(Formula), + cc: T.nilable(String), + build_bottle: T.nilable(T::Boolean), + bottle_arch: T.nilable(T::Boolean), + ).void + end + def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil) + super send(compiler) self["HOMEBREW_ENV"] = "super" @@ -89,18 +100,22 @@ def setup_build_environment(**options) private + sig { params(val: T.any(String, Pathname)).returns(String) } def cc=(val) self["HOMEBREW_CC"] = super end + sig { params(val: T.any(String, Pathname)).returns(String) } def cxx=(val) self["HOMEBREW_CXX"] = super end + sig { returns(String) } def determine_cxx determine_cc.to_s.gsub("gcc", "g++").gsub("clang", "clang++") end + sig { returns(T::Array[Pathname]) } def homebrew_extra_paths [] end @@ -115,7 +130,7 @@ def determine_path path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin") begin - path.append(gcc_version_formula(homebrew_cc).opt_bin) if homebrew_cc.match?(GNU_GCC_REGEXP) + path.append(gcc_version_formula(T.must(homebrew_cc)).opt_bin) if homebrew_cc&.match?(GNU_GCC_REGEXP) rescue FormulaUnavailableError # Don't fail and don't add these formulae to the path if they don't exist. nil @@ -124,6 +139,7 @@ def determine_path path.existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_pkg_config_paths [] end @@ -143,6 +159,7 @@ def determine_pkg_config_libdir ).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_aclocal_paths [] end @@ -156,6 +173,7 @@ def determine_aclocal_path ).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_isystem_paths [] end @@ -173,6 +191,7 @@ def determine_include_paths PATH.new(keg_only_deps.map(&:opt_include)).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_library_paths [] end @@ -187,6 +206,7 @@ def determine_library_paths PATH.new(paths).existing end + sig { returns(String) } def determine_dependencies deps.map(&:name).join(",") end @@ -199,6 +219,7 @@ def determine_cmake_prefix_path ).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_cmake_include_paths [] end @@ -208,6 +229,7 @@ def determine_cmake_include_path PATH.new(homebrew_extra_cmake_include_paths).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_cmake_library_paths [] end @@ -217,6 +239,7 @@ def determine_cmake_library_path PATH.new(homebrew_extra_cmake_library_paths).existing end + sig { returns(T::Array[Pathname]) } def homebrew_extra_cmake_frameworks_paths [] end @@ -229,14 +252,17 @@ def determine_cmake_frameworks_path ).existing end + sig { returns(String) } def determine_make_jobs Homebrew::EnvConfig.make_jobs end + sig { returns(String) } def determine_optflags Hardware::CPU.optimization_flags.fetch(effective_arch) end + sig { returns(String) } def determine_cccfg "" end @@ -246,9 +272,10 @@ def determine_cccfg # Removes the MAKEFLAGS environment variable, causing make to use a single job. # This is useful for makefiles with race conditions. # When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion. - def deparallelize + sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) } + def deparallelize(&block) old = delete("MAKEFLAGS") - if block_given? + if block begin yield ensure @@ -259,56 +286,64 @@ def deparallelize old end + sig { returns(Integer) } def make_jobs self["MAKEFLAGS"] =~ /-\w*j(\d+)/ [Regexp.last_match(1).to_i, 1].max end + sig { void } def universal_binary check_for_compiler_universal_support self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags end + sig { void } def permit_arch_flags append_to_cccfg "K" end + sig { void } def m32 append "HOMEBREW_ARCHFLAGS", "-m32" end + sig { void } def m64 append "HOMEBREW_ARCHFLAGS", "-m64" end + sig { void } def cxx11 append_to_cccfg "x" append_to_cccfg "g" if homebrew_cc == "clang" end + sig { void } def libcxx append_to_cccfg "g" if compiler == :clang end + sig { void } def libstdcxx append_to_cccfg "h" if compiler == :clang end # @private + sig { void } def refurbish_args append_to_cccfg "O" end %w[O3 O2 O1 O0 Os].each do |opt| define_method opt do - self["HOMEBREW_OPTIMIZATION_LEVEL"] = opt + send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt) end end + sig { void } def set_x11_env_if_installed; end - - def set_cpu_flags(_arg0, _arg1 = "", _arg2 = {}); end end require "extend/os/extend/ENV/super"
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -27,7 +27,7 @@ def bin def homebrew_extra_paths paths = [] - paths << MacOS::XQuartz.bin.to_s if x11? + paths << MacOS::XQuartz.bin if x11? paths end
true
Other
Homebrew
brew
0424940496d69d1520043035e0993ad9c79c5cc5.json
Add types for `ENV` extensions.
Library/Homebrew/utils/inreplace.rb
@@ -34,7 +34,7 @@ def initialize(errors) # @api public sig do params( - paths: T.any(T::Array[T.untyped], String), + paths: T.any(T::Array[T.untyped], String, Pathname), before: T.nilable(T.any(Regexp, String)), after: T.nilable(T.any(String, Symbol)), audit_result: T::Boolean,
true
Other
Homebrew
brew
c00054f3ba95d97fbcab1f13b6182809808b5770.json
sorbet: Update RBI files. Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -5841,22 +5841,6 @@ module Cask::Utils extend ::T::Private::Methods::SingletonMethodHooks end -class Caveats - def empty?(*args, &block); end - - def to_s(*args, &block); end -end - -class Checksum - def [](*args, &block); end - - def empty?(*args, &block); end - - def length(*args, &block); end - - def to_s(*args, &block); end -end - class Class def any_instance(); end @@ -11897,14 +11881,6 @@ module MachO def self.open(filename); end end -module MachOShim - def delete_rpath(*args, &block); end - - def dylib_id(*args, &block); end - - def rpaths(*args, &block); end -end - Markdown = RDiscount module Marshal @@ -15369,18 +15345,6 @@ class Pathname extend ::T::Private::Methods::SingletonMethodHooks end -class PkgVersion - def major(*args, &block); end - - def major_minor(*args, &block); end - - def major_minor_patch(*args, &block); end - - def minor(*args, &block); end - - def patch(*args, &block); end -end - class Proc include ::MethodSource::SourceLocation::ProcExtensions include ::MethodSource::MethodExtensions
false
Other
Homebrew
brew
84de3c1eb6c5f69ac08a8a4ef81060e037cc0e5c.json
python: allow multi-digit minor versions
Library/Homebrew/language/python.rb
@@ -7,7 +7,7 @@ module Language # @api public module Python def self.major_minor_version(python) - version = /\d\.\d/.match `#{python} --version 2>&1` + version = /\d\.\d+/.match `#{python} --version 2>&1` return unless version Version.create(version.to_s)
false
Other
Homebrew
brew
4e1e280ace8759de737771f1f95240a1ea3afc13.json
brew.sh: remove HOMEBREW_DEVELOPER condition This env variable is filtered out on test-bot.
Library/Homebrew/brew.sh
@@ -345,7 +345,7 @@ else : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" - if [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" && -n "$HOMEBREW_DEVELOPER" && -n "$HOMEBREW_ON_DEBIAN7" ]] + if [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" && -n "$HOMEBREW_ON_DEBIAN7" ]] then # Special version for our debian 7 docker container used to build patchelf and binutils HOMEBREW_MINIMUM_CURL_VERSION="7.25.0"
false
Other
Homebrew
brew
75e55def94d9f0d6ec5bb5422ad19091de88763d.json
brew.sh: add missing quotes
Library/Homebrew/brew.sh
@@ -345,7 +345,7 @@ else : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" - if [[ -n $HOMEBREW_FORCE_HOMEBREW_ON_LINUX && -n $HOMEBREW_DEVELOPER && -n $HOMEBREW_ON_DEBIAN7 ]] + if [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" && -n "$HOMEBREW_DEVELOPER" && -n "$HOMEBREW_ON_DEBIAN7" ]] then # Special version for our debian 7 docker container used to build patchelf and binutils HOMEBREW_MINIMUM_CURL_VERSION="7.25.0"
false
Other
Homebrew
brew
9f9eaa3e6e0837b9bfc8661bbf818aa73ed8493f.json
Remove amd-power-gadget from prerelease exceptions
Library/Homebrew/utils/shared_audits.rb
@@ -32,7 +32,6 @@ def github_release_data(user, repo, tag) end GITHUB_PRERELEASE_ALLOWLIST = { - "amd-power-gadget" => :all, "elm-format" => "0.8.3", "extraterm" => :all, "freetube" => :all,
false
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/cmd.rb
@@ -54,13 +54,23 @@ class Cmd }.freeze DEPRECATED_COMMANDS = { - Cmd::Cache => "brew --cache --cask", + Cmd::Cache => "brew --cache [--cask]", + Cmd::Audit => "brew audit [--cask]", + Cmd::Cat => "brew cat [--cask]", + Cmd::Create => "brew create --cask --set-name <name> <url>", Cmd::Doctor => "brew doctor --verbose", + Cmd::Edit => "brew edit [--cask]", + Cmd::Fetch => "brew fetch [--cask]", Cmd::Home => "brew home", - Cmd::List => "brew list --cask", - Cmd::Outdated => "brew outdated --cask", - Cmd::Reinstall => "brew reinstall", - Cmd::Upgrade => "brew upgrade --cask", + Cmd::Info => "brew info [--cask]", + Cmd::Install => "brew install [--cask]", + Cmd::List => "brew list [--cask]", + Cmd::Outdated => "brew outdated [--cask]", + Cmd::Reinstall => "brew reinstall [--cask]", + Cmd::Style => "brew style", + Cmd::Uninstall => "brew uninstall [--cask]", + Cmd::Upgrade => "brew upgrade [--cask]", + Cmd::Zap => "brew upgrade --zap [--cask]", }.freeze sig { returns(String) }
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/cmd/edit.rb
@@ -35,7 +35,9 @@ def run exec_editor cask_path rescue CaskUnavailableError => e reason = e.reason.empty? ? +"" : +"#{e.reason} " - reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.") + reason.concat( + "Run #{Formatter.identifier("brew create --cask --set-name #{e.token} <url>")} to create a new Cask.", + ) raise e.class.new(e.token, reason.freeze) end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/cmd/uninstall.rb
@@ -64,7 +64,7 @@ def self.uninstall_casks(*casks, binaries: nil, force: false, verbose: false) puts <<~EOS #{cask} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed. - Remove #{(versions.count == 1) ? "it" : "them all"} with `brew cask uninstall --force #{cask}`. + Remove #{(versions.count == 1) ? "it" : "them all"} with `brew uninstall --cask --force #{cask}`. EOS end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/dsl/caveats.rb
@@ -112,17 +112,17 @@ def eval_caveats(&block) if java_version == :any <<~EOS #{@cask} requires Java. You can install the latest version with: - brew cask install adoptopenjdk + brew install --cask adoptopenjdk EOS elsif java_version.include?("11") || java_version.include?("+") <<~EOS #{@cask} requires Java #{java_version}. You can install the latest version with: - brew cask install adoptopenjdk + brew install --cask adoptopenjdk EOS else <<~EOS #{@cask} requires Java #{java_version}. You can install it with: - brew cask install homebrew/cask-versions/adoptopenjdk#{java_version} + brew install --cask homebrew/cask-versions/adoptopenjdk#{java_version} EOS end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/exceptions.rb
@@ -111,7 +111,7 @@ class CaskAlreadyCreatedError < AbstractCaskErrorWithToken sig { returns(String) } def to_s - %Q(Cask '#{token}' already exists. Run #{Formatter.identifier("brew cask edit #{token}")} to edit it.) + %Q(Cask '#{token}' already exists. Run #{Formatter.identifier("brew edit --cask #{token}")} to edit it.) end end @@ -142,7 +142,7 @@ class CaskX11DependencyError < AbstractCaskErrorWithToken def to_s <<~EOS Cask '#{token}' requires XQuartz/X11, which can be installed using Homebrew Cask by running: - #{Formatter.identifier("brew cask install xquartz")} + #{Formatter.identifier("brew install --cask xquartz")} or manually, by downloading the package from: #{Formatter.url("https://www.xquartz.org/")}
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cask/installer.rb
@@ -474,7 +474,7 @@ def uninstall_artifacts(clear: false) end def zap - ohai %Q(Implied "brew cask uninstall #{@cask}") + ohai %Q(Implied "brew uninstall --cask #{@cask}") uninstall_artifacts if (zap_stanzas = @cask.artifacts.select { |a| a.is_a?(Artifact::Zap) }).empty? opoo "No zap stanza present for Cask '#{@cask}'"
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cmd/home.rb
@@ -1,7 +1,8 @@ -# typed: false +# typed: true # frozen_string_literal: true require "cli/parser" +require "formula" module Homebrew extend T::Sig @@ -12,14 +13,15 @@ module Homebrew def home_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `home` [<formula>] + `home` [<formula>|<cask>] - Open <formula>'s homepage in a browser, or open Homebrew's own homepage - if no formula is provided. + Open a <formula> or <cask>'s homepage in a browser, or open + Homebrew's own homepage if no argument is provided. EOS end end + sig { void } def home args = home_args.parse
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/cmd/update-report.rb
@@ -322,7 +322,7 @@ def migrate_tap_migration new_tap.install unless new_tap.installed? ohai "#{name} has been moved to Homebrew.", <<~EOS To uninstall the cask run: - brew cask uninstall --force #{name} + brew uninstall --cask --force #{name} EOS next if (HOMEBREW_CELLAR/new_name.split("/").last).directory? @@ -352,8 +352,8 @@ def migrate_tap_migration system HOMEBREW_BREW_FILE, "unlink", name ohai "brew cleanup" system HOMEBREW_BREW_FILE, "cleanup" - ohai "brew cask install #{new_name}" - system HOMEBREW_BREW_FILE, "cask", "install", new_name + ohai "brew install --cask #{new_name}" + system HOMEBREW_BREW_FILE, "install", "--cask", new_name ohai <<~EOS #{name} has been moved to Homebrew Cask. The existing keg has been unlinked. @@ -365,7 +365,7 @@ def migrate_tap_migration To uninstall the formula and install the cask run: brew uninstall --force #{name} brew tap #{new_tap_name} - brew cask install #{new_name} + brew install --cask #{new_name} EOS end else
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/dev-cmd/bump-cask-pr.rb
@@ -30,11 +30,11 @@ def bump_cask_pr_args description: "When passed with `--write`, generate a new commit after writing changes "\ "to the cask file." switch "--no-audit", - description: "Don't run `brew cask audit` before opening the PR." + description: "Don't run `brew audit` before opening the PR." switch "--online", - description: "Run `brew cask audit --online` before opening the PR." + description: "Run `brew audit --online` before opening the PR." switch "--no-style", - description: "Don't run `brew cask style --fix` before opening the PR." + description: "Don't run `brew style --fix` before opening the PR." switch "--no-browse", description: "Print the pull request URL instead of opening in a browser." switch "--no-fork", @@ -232,49 +232,49 @@ def check_closed_pull_requests(cask, tap_full_name, version:, args:) def run_cask_audit(cask, old_contents, args:) if args.dry_run? if args.no_audit? - ohai "Skipping `brew cask audit`" + ohai "Skipping `brew audit`" elsif args.online? - ohai "brew cask audit --online #{cask.sourcefile_path.basename}" + ohai "brew audit --cask --online #{cask.sourcefile_path.basename}" else - ohai "brew cask audit #{cask.sourcefile_path.basename}" + ohai "brew audit --cask #{cask.sourcefile_path.basename}" end return end failed_audit = false if args.no_audit? - ohai "Skipping `brew cask audit`" + ohai "Skipping `brew audit`" elsif args.online? - system HOMEBREW_BREW_FILE, "cask", "audit", "--online", cask.sourcefile_path + system HOMEBREW_BREW_FILE, "audit", "--cask", "--online", cask.sourcefile_path failed_audit = !$CHILD_STATUS.success? else - system HOMEBREW_BREW_FILE, "cask", "audit", cask.sourcefile_path + system HOMEBREW_BREW_FILE, "audit", "--cask", cask.sourcefile_path failed_audit = !$CHILD_STATUS.success? end return unless failed_audit cask.sourcefile_path.atomic_write(old_contents) - odie "`brew cask audit` failed!" + odie "`brew audit` failed!" end def run_cask_style(cask, old_contents, args:) if args.dry_run? if args.no_style? - ohai "Skipping `brew cask style --fix`" + ohai "Skipping `brew style --fix`" else - ohai "brew cask style --fix #{cask.sourcefile_path.basename}" + ohai "brew style --fix #{cask.sourcefile_path.basename}" end return end failed_style = false if args.no_style? - ohai "Skipping `brew cask style --fix`" + ohai "Skipping `brew style --fix`" else - system HOMEBREW_BREW_FILE, "cask", "style", "--fix", cask.sourcefile_path + system HOMEBREW_BREW_FILE, "style", "--fix", cask.sourcefile_path failed_style = !$CHILD_STATUS.success? end return unless failed_style cask.sourcefile_path.atomic_write(old_contents) - odie "`brew cask style --fix` failed!" + odie "`brew style --fix` failed!" end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/extend/os/mac/missing_formula.rb
@@ -23,13 +23,13 @@ def disallowed_reason(name) There are three versions of MacTeX. Full installation: - brew cask install mactex + brew install --cask mactex Full installation without bundled applications: - brew cask install mactex-no-gui + brew install --cask mactex-no-gui Minimal installation: - brew cask install basictex + brew install --cask basictex EOS else generic_disallowed_reason(name) @@ -47,7 +47,7 @@ def cask_reason(name, silent: false, show_info: false) def suggest_command(name, command) suggestion = <<~EOS Found a cask named "#{name}" instead. Try - brew cask #{command} #{name} + brew #{command} --cask #{name} EOS case command
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/missing_formula.rb
@@ -30,7 +30,7 @@ def disallowed_reason(name) EOS when "macruby" then <<~EOS MacRuby has been discontinued. Consider RubyMotion: - brew cask install rubymotion + brew install --cask rubymotion EOS when /(lib)?lzma/ then <<~EOS lzma is now part of the xz formula: @@ -74,8 +74,8 @@ def disallowed_reason(name) when "ngrok" then <<~EOS Upstream sunsetted 1.x in March 2016 and 2.x is not open-source. - If you wish to use the 2.x release you can install with Homebrew Cask: - brew cask install ngrok + If you wish to use the 2.x release you can install it with: + brew install --cask ngrok EOS when "cargo" then <<~EOS cargo is part of the rust formula:
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/requirement.rb
@@ -43,8 +43,8 @@ def message s = "#{class_name} unsatisfied!\n" if cask s += <<~EOS - You can install with Homebrew Cask: - brew cask install #{cask} + You can install the necessary cask with: + brew install --cask #{cask} EOS end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/requirements/java_requirement.rb
@@ -75,7 +75,7 @@ def to_str title_string = " #{title}" if title <<~EOS Install#{title_string} with Homebrew Cask: - brew cask install #{token} + brew install --cask #{token} EOS end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/test/cask/cmd_spec.rb
@@ -11,6 +11,10 @@ context "::run" do let(:noop_command) { double("Cmd::Noop", run: nil) } + before do + allow(Homebrew).to receive(:raise_deprecation_exceptions?).and_return(false) + end + it "prints help output when subcommand receives `--help` flag" do expect { described_class.run("info", "--help")
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/test/missing_formula_spec.rb
@@ -97,7 +97,7 @@ let(:show_info) { false } it { is_expected.to match(/Found a cask named "local-caffeine" instead./) } - it { is_expected.to match(/Try\n brew cask install local-caffeine/) } + it { is_expected.to match(/Try\n brew install --cask local-caffeine/) } end context "with a formula name that is a cask and show_info: true" do @@ -123,7 +123,7 @@ let(:command) { "install" } it { is_expected.to match(/Found a cask named "local-caffeine" instead./) } - it { is_expected.to match(/Try\n brew cask install local-caffeine/) } + it { is_expected.to match(/Try\n brew install --cask local-caffeine/) } end context "brew uninstall" do @@ -138,7 +138,7 @@ end it { is_expected.to match(/Found a cask named "local-caffeine" instead./) } - it { is_expected.to match(/Try\n brew cask uninstall local-caffeine/) } + it { is_expected.to match(/Try\n brew uninstall --cask local-caffeine/) } end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
Library/Homebrew/test/requirements/java_requirement_spec.rb
@@ -138,21 +138,21 @@ def setup_java_with_version(version) describe "#suggestion" do context "without specific version" do - its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) } + its(:suggestion) { is_expected.to match(/brew install --cask adoptopenjdk/) } its(:cask) { is_expected.to eq("adoptopenjdk") } end context "with version 1.8" do subject { described_class.new(%w[1.8]) } - its(:suggestion) { is_expected.to match(%r{brew cask install homebrew/cask-versions/adoptopenjdk8}) } + its(:suggestion) { is_expected.to match(%r{brew install --cask homebrew/cask-versions/adoptopenjdk8}) } its(:cask) { is_expected.to eq("homebrew/cask-versions/adoptopenjdk8") } end context "with version 1.8+" do subject { described_class.new(%w[1.8+]) } - its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) } + its(:suggestion) { is_expected.to match(/brew install --cask adoptopenjdk/) } its(:cask) { is_expected.to eq("adoptopenjdk") } end end
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
docs/Manpage.md
@@ -71,39 +71,9 @@ Homebrew Cask provides a friendly CLI workflow for the administration of macOS a Commands: -- `audit` - <br>Check *`cask`* for Homebrew coding style violations. - -- `cat` - <br>Dump raw source of a *`cask`* to the standard output. - -- `create` - <br>Creates the given *`cask`* and opens it in an editor. - -- `edit` - <br>Open the given *`cask`* for editing. - -- `fetch` - <br>Downloads remote application files to local cache. - - `help` <br>Print help for `cask` commands. -- `info` - <br>Displays information about the given *`cask`*. - -- `install` - <br>Installs the given *`cask`*. - -- `style` - <br>Checks style of the given *`cask`* using RuboCop. - -- `uninstall` - <br>Uninstalls the given *`cask`*. - -- `zap` - <br>Zaps all files associated with the given *`cask`*. - See also: `man brew` ### `cleanup` [*`options`*] [*`formula`*|*`cask`*] @@ -243,10 +213,10 @@ error message if no logs are found. * `-p`, `--private`: The Gist will be marked private and will not appear in listings but will be accessible with its link. -### `home` [*`formula`*] +### `home` [*`formula`*|*`cask`*] -Open *`formula`*'s homepage in a browser, or open Homebrew's own homepage -if no formula is provided. +Open a *`formula`* or *`cask`*'s homepage in a browser, or open +Homebrew's own homepage if no argument is provided. ### `info` [*`options`*] [*`formula`*|*`cask`*] @@ -849,11 +819,11 @@ supplied by the user. * `--commit`: When passed with `--write`, generate a new commit after writing changes to the cask file. * `--no-audit`: - Don't run `brew cask audit` before opening the PR. + Don't run `brew audit` before opening the PR. * `--online`: - Run `brew cask audit --online` before opening the PR. + Run `brew audit --online` before opening the PR. * `--no-style`: - Don't run `brew cask style --fix` before opening the PR. + Don't run `brew style --fix` before opening the PR. * `--no-browse`: Print the pull request URL instead of opening in a browser. * `--no-fork`:
true
Other
Homebrew
brew
3c2ec1c60f942ef7fe935ddf92272fc91c094306.json
Deprecate remaining cask commands.
manpages/brew.1
@@ -67,71 +67,11 @@ Homebrew Cask provides a friendly CLI workflow for the administration of macOS a Commands: . .TP -\fBaudit\fR -. -.br -Check \fIcask\fR for Homebrew coding style violations\. -. -.TP -\fBcat\fR -. -.br -Dump raw source of a \fIcask\fR to the standard output\. -. -.TP -\fBcreate\fR -. -.br -Creates the given \fIcask\fR and opens it in an editor\. -. -.TP -\fBedit\fR -. -.br -Open the given \fIcask\fR for editing\. -. -.TP -\fBfetch\fR -. -.br -Downloads remote application files to local cache\. -. -.TP \fBhelp\fR . .br Print help for \fBcask\fR commands\. . -.TP -\fBinfo\fR -. -.br -Displays information about the given \fIcask\fR\. -. -.TP -\fBinstall\fR -. -.br -Installs the given \fIcask\fR\. -. -.TP -\fBstyle\fR -. -.br -Checks style of the given \fIcask\fR using RuboCop\. -. -.TP -\fBuninstall\fR -. -.br -Uninstalls the given \fIcask\fR\. -. -.TP -\fBzap\fR -. -.br -Zaps all files associated with the given \fIcask\fR\. -. .P See also: \fBman brew\fR . @@ -322,8 +262,8 @@ Automatically create a new issue in the appropriate GitHub repository after crea \fB\-p\fR, \fB\-\-private\fR The Gist will be marked private and will not appear in listings but will be accessible with its link\. . -.SS "\fBhome\fR [\fIformula\fR]" -Open \fIformula\fR\'s homepage in a browser, or open Homebrew\'s own homepage if no formula is provided\. +.SS "\fBhome\fR [\fIformula\fR|\fIcask\fR]" +Open a \fIformula\fR or \fIcask\fR\'s homepage in a browser, or open Homebrew\'s own homepage if no argument is provided\. . .SS "\fBinfo\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]" Display brief statistics for your Homebrew installation\. @@ -1173,15 +1113,15 @@ When passed with \fB\-\-write\fR, generate a new commit after writing changes to . .TP \fB\-\-no\-audit\fR -Don\'t run \fBbrew cask audit\fR before opening the PR\. +Don\'t run \fBbrew audit\fR before opening the PR\. . .TP \fB\-\-online\fR -Run \fBbrew cask audit \-\-online\fR before opening the PR\. +Run \fBbrew audit \-\-online\fR before opening the PR\. . .TP \fB\-\-no\-style\fR -Don\'t run \fBbrew cask style \-\-fix\fR before opening the PR\. +Don\'t run \fBbrew style \-\-fix\fR before opening the PR\. . .TP \fB\-\-no\-browse\fR
true
Other
Homebrew
brew
6449e0f7bf2da80b4a0fbb710f753076c7e4a11a.json
Ignore Sorbet error 5061 for now. See https://github.com/sorbet/sorbet/pull/3565#issuecomment-730544936.
Library/Homebrew/sorbet/config
@@ -9,3 +9,6 @@ --dsl-plugins sorbet/triggers.yml + +--error-black-list +5061
false
Other
Homebrew
brew
41150862840af1ceb61eace883117ae72ead5941.json
Add Sorbet plugin for `delegate`.
Library/Homebrew/sorbet/plugins/delegate.rb
@@ -0,0 +1,21 @@ +# typed: strict +# frozen_string_literal: true + +source = ARGV[5] + +methods = if (single = source[/delegate\s+([^:]+):\s+/, 1]) + [single] +else + multiple = source[/delegate\s+\[(.*?)\]\s+=>\s+/m, 1] + non_comments = multiple.gsub(/\#.*$/, "") + non_comments.scan(/:([^:,\s]+)/).flatten +end + +methods.each do |method| + puts <<~RUBY + # typed: strict + + sig {params(arg0: T.untyped).returns(T.untyped)} + def #{method}(*arg0); end + RUBY +end
true
Other
Homebrew
brew
41150862840af1ceb61eace883117ae72ead5941.json
Add Sorbet plugin for `delegate`.
Library/Homebrew/sorbet/triggers.yml
@@ -4,3 +4,4 @@ ruby_extra_args: triggers: using: sorbet/plugins/unpack_strategy_magic.rb attr_predicate: sorbet/plugins/attr_predicate.rb + delegate: sorbet/plugins/delegate.rb
true
Other
Homebrew
brew
257855a92967fff105f3176ffb4c48c034a4702f.json
Run `sorbet` workflow on macOS.
.github/workflows/sorbet.yml
@@ -10,7 +10,7 @@ on: jobs: tapioca: if: github.repository == 'Homebrew/brew' - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Set up Homebrew id: set-up-homebrew
false
Other
Homebrew
brew
444c3858dfc79a51cd48312bf65bccb23525a87f.json
Adjust macOS version logic - Adjust latest supported macOS logic for e.g. Big Sur 11.1. - Updated latest supported version in docs to Mojave Fixes https://github.com/Homebrew/brew/issues/9211
Library/Homebrew/os/mac.rb
@@ -44,13 +44,6 @@ def latest_sdk_version Version.new "11.0" end - def latest_stable_version - # TODO: bump version when new macOS is released and also update - # references in docs/Installation.md and - # https://github.com/Homebrew/install/blob/HEAD/install.sh - Version.new "11.0" - end - def outdated_release? # TODO: bump version when new macOS is released and also update # references in docs/Installation.md and @@ -59,7 +52,10 @@ def outdated_release? end def prerelease? - version > latest_stable_version + # TODO: bump version when new macOS is released or announced + # and also update references in docs/Installation.md and + # https://github.com/Homebrew/install/blob/HEAD/install.sh + version >= "12.0" end def languages
true
Other
Homebrew
brew
444c3858dfc79a51cd48312bf65bccb23525a87f.json
Adjust macOS version logic - Adjust latest supported macOS logic for e.g. Big Sur 11.1. - Updated latest supported version in docs to Mojave Fixes https://github.com/Homebrew/brew/issues/9211
Library/Homebrew/os/mac/xcode.rb
@@ -22,7 +22,7 @@ module Xcode def latest_version latest_stable = "12.2" case MacOS.version - when "11.0" then latest_stable + when /^11\./ then latest_stable when "10.15" then "12.2" when "10.14" then "11.3.1" when "10.13" then "10.1" @@ -45,7 +45,7 @@ def latest_version sig { returns(String) } def minimum_version case MacOS.version - when "11.0" then "12.2" + when /^11\./ then "12.2" when "10.15" then "11.0" when "10.14" then "10.2" when "10.13" then "9.0" @@ -275,7 +275,7 @@ def update_instructions sig { returns(String) } def latest_clang_version case MacOS.version - when "11.0", "10.15" then "1200.0.32.27" + when /^11\./, "10.15" then "1200.0.32.27" when "10.14" then "1100.0.33.17" when "10.13" then "1000.10.44.2" when "10.12" then "900.0.39.2" @@ -291,7 +291,7 @@ def latest_clang_version sig { returns(String) } def minimum_version case MacOS.version - when "11.0" then "12.0.0" + when /^11\./ then "12.0.0" when "10.15" then "11.0.0" when "10.14" then "10.0.0" when "10.13" then "9.0.0"
true
Other
Homebrew
brew
444c3858dfc79a51cd48312bf65bccb23525a87f.json
Adjust macOS version logic - Adjust latest supported macOS logic for e.g. Big Sur 11.1. - Updated latest supported version in docs to Mojave Fixes https://github.com/Homebrew/brew/issues/9211
docs/Installation.md
@@ -11,7 +11,7 @@ it does it too. You have to confirm everything it will do before it starts. ## macOS Requirements * A 64-bit Intel CPU <sup>[1](#1)</sup> -* macOS High Sierra (10.13) (or higher) <sup>[2](#2)</sup> +* macOS Mojave (10.14) (or higher) <sup>[2](#2)</sup> * Command Line Tools (CLT) for Xcode: `xcode-select --install`, [developer.apple.com/downloads](https://developer.apple.com/downloads) or [Xcode](https://itunes.apple.com/us/app/xcode/id497799835) <sup>[3](#3)</sup> @@ -52,7 +52,7 @@ Uninstallation is documented in the [FAQ](FAQ.md). <a name="1"><sup>1</sup></a> For 32-bit or PPC support see [Tigerbrew](https://github.com/mistydemeo/tigerbrew). -<a name="2"><sup>2</sup></a> 10.13 or higher is recommended. 10.9–10.12 are +<a name="2"><sup>2</sup></a> 10.14 or higher is recommended. 10.9–10.13 are supported on a best-effort basis. For 10.4-10.6 see [Tigerbrew](https://github.com/mistydemeo/tigerbrew).
true
Other
Homebrew
brew
67e4e78f227873c8c4e49f37de1c8c9e58a3ee83.json
fix typo in audit tests Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Markus Reiter <me@reitermark.us>
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -423,7 +423,7 @@ class Cask < Formula .to eq 'Formula license ["0BSD"] does not match GitHub license ["GPL-3.0"].' end - it "allows a formula-specified license that differes from its GitHub "\ + it "allows a formula-specified license that differs from its GitHub "\ "repository for formulae on the mismatched license allowlist" do formula_text = <<~RUBY class Cask < Formula
false
Other
Homebrew
brew
b0d10fdf28869e1f599e5e97ce2e9a1a8573d9a9.json
add audit tests for migrated audit exception lists
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -560,6 +560,91 @@ class Foo < Formula end end + describe "#audit_specs" do + let(:throttle_list) { { throttled_formulae: { "foo" => 10 } } } + let(:versioned_head_spec_list) { { versioned_head_spec_allowlist: ["foo"] } } + + it "allows versions with no throttle rate" do + fa = formula_auditor "bar", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list + class Bar < Formula + url "https://brew.sh/foo-1.0.1.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems).to be_empty + end + + it "allows major/minor versions with throttle rate" do + fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list + class Foo < Formula + url "https://brew.sh/foo-1.0.0.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems).to be_empty + end + + it "allows patch versions to be multiples of the throttle rate" do + fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list + class Foo < Formula + url "https://brew.sh/foo-1.0.10.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems).to be_empty + end + + it "doesn't allow patch versions that aren't multiples of the throttle rate" do + fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list + class Foo < Formula + url "https://brew.sh/foo-1.0.1.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems.first[:message]).to match "should only be updated every 10 releases on multiples of 10" + end + + it "allows non-versioned formulae to have a `HEAD` spec" do + fa = formula_auditor "bar", <<~RUBY, core_tap: true, tap_audit_exceptions: versioned_head_spec_list + class Bar < Formula + url "https://brew.sh/foo-1.0.tgz" + head "https://brew.sh/foo-1.0.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems).to be_empty + end + + it "doesn't allow versioned formulae to have a `HEAD` spec" do + fa = formula_auditor "bar@1", <<~RUBY, core_tap: true, tap_audit_exceptions: versioned_head_spec_list + class BarAT1 < Formula + url "https://brew.sh/foo-1.0.tgz" + head "https://brew.sh/foo-1.0.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems.first[:message]).to match "Versioned formulae should not have a `HEAD` spec" + end + + it "allows ersioned formulae on the allowlist to have a `HEAD` spec" do + fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: versioned_head_spec_list + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + head "https://brew.sh/foo-1.0.tgz" + end + RUBY + + fa.audit_specs + expect(fa.problems).to be_empty + end + end + describe "#audit_deps" do describe "a dependency on a macOS-provided keg-only formula" do describe "which is allowlisted" do
false
Other
Homebrew
brew
70dd41cfd8eee95f3ed4daacf665ae62b82695db.json
Add type signatures to `BuildEnvironment`.
Library/Homebrew/build_environment.rb
@@ -1,34 +1,44 @@ -# typed: false +# typed: true # frozen_string_literal: true # Settings for the build environment. # # @api private class BuildEnvironment + extend T::Sig + + sig { params(settings: Symbol).void } def initialize(*settings) - @settings = Set.new(*settings) + @settings = Set.new(settings) end + sig { params(args: T::Enumerable[Symbol]).returns(T.self_type) } def merge(*args) @settings.merge(*args) self end + sig { params(o: Symbol).returns(T.self_type) } def <<(o) @settings << o self end + sig { returns(T::Boolean) } def std? @settings.include? :std end + sig { returns(T::Boolean) } def userpaths? @settings.include? :userpaths end # DSL for specifying build environment settings. module DSL + extend T::Sig + + sig { params(settings: Symbol).returns(BuildEnvironment) } def env(*settings) @env ||= BuildEnvironment.new @env.merge(settings) @@ -50,16 +60,18 @@ def env(*settings) ].freeze private_constant :KEYS + sig { params(env: T.untyped).returns(T::Array[String]) } def self.keys(env) KEYS & env.keys end + sig { params(env: T.untyped, f: IO).void } def self.dump(env, f = $stdout) keys = self.keys(env) keys -= %w[CC CXX OBJC OBJCXX] if env["CC"] == env["HOMEBREW_CC"] keys.each do |key| - value = env[key] + value = env.fetch(key) s = +"#{key}: #{value}" case key when "CC", "CXX", "LD"
true
Other
Homebrew
brew
70dd41cfd8eee95f3ed4daacf665ae62b82695db.json
Add type signatures to `BuildEnvironment`.
Library/Homebrew/cmd/--env.rb
@@ -47,11 +47,10 @@ def __env Utils::Shell.from_path(args.shell) end - env_keys = BuildEnvironment.keys(ENV) if shell.nil? BuildEnvironment.dump ENV else - env_keys.each do |key| + BuildEnvironment.keys(ENV).each do |key| puts Utils::Shell.export_value(key, ENV[key], shell) end end
true
Other
Homebrew
brew
64a0e9a7215878d8ce3eccf47c2434d596bfaffb.json
Add type signatures for `Caskroom`.
Library/.rubocop.yml
@@ -18,6 +18,7 @@ AllCops: - 'Homebrew/sorbet/rbi/gems/**/*.rbi' - 'Homebrew/sorbet/rbi/hidden-definitions/**/*.rbi' - 'Homebrew/sorbet/rbi/todo.rbi' + - 'Homebrew/sorbet/rbi/upstream.rbi' - 'Homebrew/bin/*' - 'Homebrew/vendor/**/*'
true
Other
Homebrew
brew
64a0e9a7215878d8ce3eccf47c2434d596bfaffb.json
Add type signatures for `Caskroom`.
Library/Homebrew/cask/caskroom.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "utils/user" @@ -10,13 +10,13 @@ module Cask module Caskroom extend T::Sig - module_function - - def path + sig { returns(Pathname) } + def self.path @path ||= HOMEBREW_PREFIX.join("Caskroom") end - def ensure_caskroom_exists + sig { void } + def self.ensure_caskroom_exists return if path.exist? sudo = !path.parent.writable? @@ -32,8 +32,8 @@ def ensure_caskroom_exists SystemCommand.run("/usr/bin/chgrp", args: ["admin", path], sudo: sudo) end - sig { params(config: Config).returns(T::Array[Cask]) } - def casks(config: nil) + sig { params(config: T.nilable(Config)).returns(T::Array[Cask]) } + def self.casks(config: nil) return [] unless path.exist? Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path|
true
Other
Homebrew
brew
64a0e9a7215878d8ce3eccf47c2434d596bfaffb.json
Add type signatures for `Caskroom`.
Library/Homebrew/sorbet/rbi/upstream.rbi
@@ -0,0 +1,7 @@ +# typed: strict + +class Pathname + # https://github.com/sorbet/sorbet/pull/3676 + sig { params(p1: T.any(String, Pathname), p2: String).returns(T::Array[Pathname]) } + def self.glob(p1, p2 = T.unsafe(nil)); end +end
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/dev-cmd/audit.rb
@@ -16,6 +16,7 @@ require "digest" require "cli/parser" require "json" +require "formula_auditor" require "tap_auditor" module Homebrew @@ -218,977 +219,4 @@ def format_problem_lines(problems) def format_problem(message, location) "* #{location&.to_s&.dup&.concat(": ")}#{message.chomp.gsub("\n", "\n ")}" end - - class FormulaText - def initialize(path) - @text = path.open("rb", &:read) - @lines = @text.lines.to_a - end - - def without_patch - @text.split("\n__END__").first - end - - def trailing_newline? - /\Z\n/ =~ @text - end - - def =~(other) - other =~ @text - end - - def include?(s) - @text.include? s - end - - def line_number(regex, skip = 0) - index = @lines.drop(skip).index { |line| line =~ regex } - index ? index + 1 : nil - end - - def reverse_line_number(regex) - index = @lines.reverse.index { |line| line =~ regex } - index ? @lines.count - index : nil - end - end - - class FormulaAuditor - include FormulaCellarChecks - - attr_reader :formula, :text, :problems, :new_formula_problems - - def initialize(formula, options = {}) - @formula = formula - @versioned_formula = formula.versioned_formula? - @new_formula_inclusive = options[:new_formula] - @new_formula = options[:new_formula] && !@versioned_formula - @strict = options[:strict] - @online = options[:online] - @build_stable = options[:build_stable] - @git = options[:git] - @display_cop_names = options[:display_cop_names] - @only = options[:only] - @except = options[:except] - # Accept precomputed style offense results, for efficiency - @style_offenses = options[:style_offenses] - # Allow the formula tap to be set as homebrew/core, for testing purposes - @core_tap = formula.tap&.core_tap? || options[:core_tap] - @problems = [] - @new_formula_problems = [] - @text = FormulaText.new(formula.path) - @specs = %w[stable head].map { |s| formula.send(s) }.compact - @spdx_license_data = options[:spdx_license_data] - @spdx_exception_data = options[:spdx_exception_data] - @tap_audit_exceptions = options[:tap_audit_exceptions] - end - - def audit_style - return unless @style_offenses - - @style_offenses.each do |offense| - correction_status = "#{Tty.green}[Corrected]#{Tty.reset} " if offense.corrected? - - cop_name = "#{offense.cop_name}: " if @display_cop_names - message = "#{cop_name}#{correction_status}#{offense.message}" - - problem message, location: offense.location - end - end - - def audit_file - if formula.core_formula? && @versioned_formula - unversioned_formula = begin - # build this ourselves as we want e.g. homebrew/core to be present - full_name = if formula.tap - "#{formula.tap}/#{formula.name}" - else - formula.name - end - Formulary.factory(full_name.gsub(/@.*$/, "")).path - rescue FormulaUnavailableError, TapFormulaAmbiguityError, - TapFormulaWithOldnameAmbiguityError - Pathname.new formula.path.to_s.gsub(/@.*\.rb$/, ".rb") - end - unless unversioned_formula.exist? - unversioned_name = unversioned_formula.basename(".rb") - problem "#{formula} is versioned but no #{unversioned_name} formula exists" - end - elsif @build_stable && - formula.stable? && - !@versioned_formula && - (versioned_formulae = formula.versioned_formulae - [formula]) && - versioned_formulae.present? - versioned_aliases = formula.aliases.grep(/.@\d/) - _, last_alias_version = versioned_formulae.map(&:name).last.split("@") - alias_name_major = "#{formula.name}@#{formula.version.major}" - alias_name_major_minor = "#{alias_name_major}.#{formula.version.minor}" - alias_name = if last_alias_version.split(".").length == 1 - alias_name_major - else - alias_name_major_minor - end - valid_alias_names = [alias_name_major, alias_name_major_minor] - - unless @core_tap - versioned_aliases.map! { |a| "#{formula.tap}/#{a}" } - valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } - end - - # Fix naming based on what people expect. - if alias_name_major_minor == "adoptopenjdk@1.8" - valid_alias_names << "adoptopenjdk@8" - valid_alias_names.delete "adoptopenjdk@1" - end - - valid_versioned_aliases = versioned_aliases & valid_alias_names - invalid_versioned_aliases = versioned_aliases - valid_alias_names - - if valid_versioned_aliases.empty? - if formula.tap - problem <<~EOS - Formula has other versions so create a versioned alias: - cd #{formula.tap.alias_dir} - ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name} - EOS - else - problem "Formula has other versions so create an alias named #{alias_name}." - end - end - - if invalid_versioned_aliases.present? - problem <<~EOS - Formula has invalid versioned aliases: - #{invalid_versioned_aliases.join("\n ")} - EOS - end - end - end - - def self.aliases - # core aliases + tap alias names + tap alias full name - @aliases ||= Formula.aliases + Formula.tap_aliases - end - - def audit_formula_name - return unless @strict - return unless @core_tap - - name = formula.name - - problem "'#{name}' is not allowed in homebrew/core." if MissingFormula.disallowed_reason(name) - - if Formula.aliases.include? name - problem "Formula name conflicts with existing aliases in homebrew/core." - return - end - - if oldname = CoreTap.instance.formula_renames[name] - problem "'#{name}' is reserved as the old name of #{oldname} in homebrew/core." - return - end - - return if formula.core_formula? - return unless Formula.core_names.include?(name) - - problem "Formula name conflicts with existing core formula." - end - - PROVIDED_BY_MACOS_DEPENDS_ON_ALLOWLIST = %w[ - apr - apr-util - libressl - openblas - openssl@1.1 - ].freeze - - PERMITTED_LICENSE_MISMATCHES = { - "AGPL-3.0" => ["AGPL-3.0-only", "AGPL-3.0-or-later"], - "GPL-2.0" => ["GPL-2.0-only", "GPL-2.0-or-later"], - "GPL-3.0" => ["GPL-3.0-only", "GPL-3.0-or-later"], - "LGPL-2.1" => ["LGPL-2.1-only", "LGPL-2.1-or-later"], - "LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"], - }.freeze - - PERMITTED_FORMULA_LICENSE_MISMATCHES = { - "cmockery" => "0.1.2", - "scw@1" => "1.20", - }.freeze - - def audit_license - if formula.license.present? - licenses, exceptions = SPDX.parse_license_expression formula.license - - non_standard_licenses = licenses.reject { |license| SPDX.valid_license? license } - if non_standard_licenses.present? - problem <<~EOS - Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}. - For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} - EOS - end - - if @strict - deprecated_licenses = licenses.select do |license| - SPDX.deprecated_license? license - end - if deprecated_licenses.present? - problem <<~EOS - Formula #{formula.name} contains deprecated SPDX licenses: #{deprecated_licenses}. - You may need to add `-only` or `-or-later` for GNU licenses (e.g. `GPL`, `LGPL`, `AGPL`, `GFDL`). - For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} - EOS - end - end - - invalid_exceptions = exceptions.reject { |exception| SPDX.valid_license_exception? exception } - if invalid_exceptions.present? - problem <<~EOS - Formula #{formula.name} contains invalid or deprecated SPDX license exceptions: #{invalid_exceptions}. - For a list of valid license exceptions check: - #{Formatter.url("https://spdx.org/licenses/exceptions-index.html")} - EOS - end - - return unless @online - - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) - return if user.blank? - - github_license = GitHub.get_repo_license(user, repo) - return unless github_license - return if (licenses + ["NOASSERTION"]).include?(github_license) - return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license } - return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version - - problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}." - - elsif @new_formula && @core_tap - problem "Formulae in homebrew/core must specify a license." - end - end - - # TODO: try to remove these, it's not a good user experience - VERSIONED_DEPENDENCIES_CONFLICTS_ALLOWLIST = %w[ - agda - anjuta - fdroidserver - gradio - predictionio - sqoop - visp - ].freeze - - def audit_deps - @specs.each do |spec| - # Check for things we don't like to depend on. - # We allow non-Homebrew installs whenever possible. - spec.deps.each do |dep| - begin - dep_f = dep.to_formula - rescue TapFormulaUnavailableError - # Don't complain about missing cross-tap dependencies - next - rescue FormulaUnavailableError - problem "Can't find dependency #{dep.name.inspect}." - next - rescue TapFormulaAmbiguityError - problem "Ambiguous dependency #{dep.name.inspect}." - next - rescue TapFormulaWithOldnameAmbiguityError - problem "Ambiguous oldname dependency #{dep.name.inspect}." - next - end - - if dep_f.oldname && dep.name.split("/").last == dep_f.oldname - problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'." - end - - if self.class.aliases.include?(dep.name) && - dep_f.core_formula? && !dep_f.versioned_formula? - problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \ - "use the canonical name '#{dep.to_formula.full_name}'." - end - - if @core_tap && - @new_formula && - dep_f.keg_only? && - dep_f.keg_only_reason.provided_by_macos? && - dep_f.keg_only_reason.applicable? && - !PROVIDED_BY_MACOS_DEPENDS_ON_ALLOWLIST.include?(dep.name) - new_formula_problem( - "Dependency '#{dep.name}' is provided by macOS; " \ - "please replace 'depends_on' with 'uses_from_macos'.", - ) - end - - dep.options.each do |opt| - next if @core_tap - next if dep_f.option_defined?(opt) - next if dep_f.requirements.find do |r| - if r.recommended? - opt.name == "with-#{r.name}" - elsif r.optional? - opt.name == "without-#{r.name}" - end - end - - problem "Dependency #{dep} does not define option #{opt.name.inspect}" - end - - problem "Don't use git as a dependency (it's always available)" if @new_formula && dep.name == "git" - - problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run) - - next unless @core_tap - - if dep.tags.include?(:recommended) || dep.tags.include?(:optional) - problem "Formulae in homebrew/core should not have optional or recommended dependencies" - end - end - - next unless @core_tap - - if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any? - problem "Formulae in homebrew/core should not have optional or recommended requirements" - end - end - - return unless @core_tap - return if VERSIONED_DEPENDENCIES_CONFLICTS_ALLOWLIST.include?(formula.name) - - # The number of conflicts on Linux is absurd. - # TODO: remove this and check these there too. - return if OS.linux? - - recursive_runtime_formulae = formula.runtime_formula_dependencies(undeclared: false) - version_hash = {} - version_conflicts = Set.new - recursive_runtime_formulae.each do |f| - name = f.name - unversioned_name, = name.split("@") - version_hash[unversioned_name] ||= Set.new - version_hash[unversioned_name] << name - next if version_hash[unversioned_name].length < 2 - - version_conflicts += version_hash[unversioned_name] - end - - return if version_conflicts.empty? - - problem <<~EOS - #{formula.full_name} contains conflicting version recursive dependencies: - #{version_conflicts.to_a.join ", "} - View these with `brew deps --tree #{formula.full_name}`. - EOS - end - - def audit_conflicts - formula.conflicts.each do |c| - Formulary.factory(c.name) - rescue TapFormulaUnavailableError - # Don't complain about missing cross-tap conflicts. - next - rescue FormulaUnavailableError - problem "Can't find conflicting formula #{c.name.inspect}." - rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError - problem "Ambiguous conflicting formula #{c.name.inspect}." - end - end - - def audit_postgresql - return unless formula.name == "postgresql" - return unless @core_tap - - major_version = formula.version.major.to_i - previous_major_version = major_version - 1 - previous_formula_name = "postgresql@#{previous_major_version}" - begin - Formula[previous_formula_name] - rescue FormulaUnavailableError - problem "Versioned #{previous_formula_name} in homebrew/core must be created for " \ - "`brew-postgresql-upgrade-database` and `pg_upgrade` to work." - end - end - - # openssl@1.1 only needed for Linux - VERSIONED_KEG_ONLY_ALLOWLIST = %w[ - autoconf@2.13 - bash-completion@2 - clang-format@8 - gnupg@1.4 - libsigc++@2 - lua@5.1 - numpy@1.16 - openssl@1.1 - python@3.8 - python@3.9 - ].freeze - - def audit_versioned_keg_only - return unless @versioned_formula - return unless @core_tap - - if formula.keg_only? - return if formula.keg_only_reason.versioned_formula? - if formula.name.start_with?("openssl", "libressl") && - formula.keg_only_reason.by_macos? - return - end - end - - return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name) - return if formula.name.start_with?("adoptopenjdk@") - return if formula.name.start_with?("gcc@") - - problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`" - end - - CERT_ERROR_ALLOWLIST = { - "hashcat" => "https://hashcat.net/hashcat/", - "jinx" => "https://www.jinx-lang.org/", - "lmod" => "https://www.tacc.utexas.edu/research-development/tacc-projects/lmod", - "micropython" => "https://www.micropython.org/", - "monero" => "https://www.getmonero.org/", - }.freeze - - def audit_homepage - homepage = formula.homepage - - return if homepage.nil? || homepage.empty? - - return unless @online - - return if CERT_ERROR_ALLOWLIST[formula.name] == homepage - - return unless DevelopmentTools.curl_handles_most_https_certificates? - - if http_content_problem = curl_check_http_content(homepage, - user_agents: [:browser, :default], - check_content: true, - strict: @strict) - problem http_content_problem - end - end - - def audit_bottle_spec - # special case: new versioned formulae should be audited - return unless @new_formula_inclusive - return unless @core_tap - - return if formula.bottle_disabled? - - return unless formula.bottle_defined? - - new_formula_problem "New formulae in homebrew/core should not have a `bottle do` block" - end - - def audit_bottle_disabled - return unless formula.bottle_disabled? - return if formula.bottle_unneeded? - - problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid? - - return unless @core_tap - - problem "Formulae in homebrew/core should not use `bottle :disabled`" - end - - def audit_github_repository_archived - return if formula.deprecated? - - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @online - return if user.blank? - - metadata = SharedAudits.github_repo_data(user, repo) - return if metadata.nil? - - problem "GitHub repo is archived" if metadata["archived"] - end - - def audit_gitlab_repository_archived - return if formula.deprecated? - - user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if @online - return if user.blank? - - metadata = SharedAudits.gitlab_repo_data(user, repo) - return if metadata.nil? - - problem "GitLab repo is archived" if metadata["archived"] - end - - def audit_github_repository - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula - - return if user.blank? - - warning = SharedAudits.github(user, repo) - return if warning.nil? - - new_formula_problem warning - end - - def audit_gitlab_repository - user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if @new_formula - return if user.blank? - - warning = SharedAudits.gitlab(user, repo) - return if warning.nil? - - new_formula_problem warning - end - - def audit_bitbucket_repository - user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*}) if @new_formula - return if user.blank? - - warning = SharedAudits.bitbucket(user, repo) - return if warning.nil? - - new_formula_problem warning - end - - def get_repo_data(regex) - return unless @core_tap - return unless @online - - _, user, repo = *regex.match(formula.stable.url) if formula.stable - _, user, repo = *regex.match(formula.homepage) unless user - _, user, repo = *regex.match(formula.head.url) if !user && formula.head - return if !user || !repo - - repo.delete_suffix!(".git") - - [user, repo] - end - - UNSTABLE_ALLOWLIST = { - "aalib" => "1.4rc", - "automysqlbackup" => "3.0-rc", - "aview" => "1.3.0rc", - "elm-format" => "0.6.0-alpha", - "ftgl" => "2.1.3-rc", - "hidapi" => "0.8.0-rc", - "libcaca" => "0.99b", - "premake" => "4.4-beta", - "pwnat" => "0.3-beta", - "recode" => "3.7-beta", - "speexdsp" => "1.2rc", - "sqoop" => "1.4.", - "tcptraceroute" => "1.5beta", - "tiny-fugue" => "5.0b", - "vbindiff" => "3.0_beta", - }.freeze - - # Used for formulae that are unstable but need CI run without being in homebrew/core - UNSTABLE_DEVEL_ALLOWLIST = { - }.freeze - - GNOME_DEVEL_ALLOWLIST = { - "libart" => "2.3", - "gtk-mac-integration" => "2.1", - "gtk-doc" => "1.31", - "gcab" => "1.3", - "libepoxy" => "1.5", - }.freeze - - def audit_specs - problem "Head-only (no stable download)" if head_only?(formula) - - %w[Stable HEAD].each do |name| - spec_name = name.downcase.to_sym - next unless spec = formula.send(spec_name) - - ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit - ra.problems.each do |message| - problem "#{name}: #{message}" - end - - spec.resources.each_value do |resource| - problem "Resource name should be different from the formula name" if resource.name == formula.name - - ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit - ra.problems.each do |message| - problem "#{name} resource #{resource.name.inspect}: #{message}" - end - end - - next if spec.patches.empty? - next unless @new_formula - - new_formula_problem( - "Formulae should not require patches to build. " \ - "Patches should be submitted and accepted upstream first.", - ) - end - - if stable = formula.stable - version = stable.version - problem "Stable: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/ - if version.to_s.start_with?("HEAD") - problem "Stable: non-HEAD version name (#{version}) should not begin with HEAD" - end - end - - return unless @core_tap - - if formula.head && @versioned_formula && - !tap_audit_exception(:versioned_head_spec_allowlist, formula.name) - problem "Versioned formulae should not have a `HEAD` spec" - end - - stable = formula.stable - return unless stable - return unless stable.url - - stable_version_string = stable.version.to_s - stable_url_version = Version.parse(stable.url) - stable_url_minor_version = stable_url_version.minor.to_i - - formula_suffix = stable.version.patch.to_i - throttled_rate = tap_audit_exception(:throttled_formulae, formula.name) - if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? - problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" - end - - case (url = stable.url) - when /[\d._-](alpha|beta|rc\d)/ - matched = Regexp.last_match(1) - version_prefix = stable_version_string.sub(/\d+$/, "") - return if UNSTABLE_ALLOWLIST[formula.name] == version_prefix - return if UNSTABLE_DEVEL_ALLOWLIST[formula.name] == version_prefix - - problem "Stable version URLs should not contain #{matched}" - when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i - version_prefix = stable.version.major_minor - return if GNOME_DEVEL_ALLOWLIST[formula.name] == version_prefix - return if stable_url_version < Version.create("1.0") - return if stable_url_minor_version.even? - - problem "#{stable.version} is a development release" - when %r{isc.org/isc/bind\d*/}i - return if stable_url_minor_version.even? - - problem "#{stable.version} is a development release" - - when %r{https?://gitlab\.com/([\w-]+)/([\w-]+)} - owner = Regexp.last_match(1) - repo = Regexp.last_match(2) - - tag = SharedAudits.gitlab_tag_from_url(url) - tag ||= stable.specs[:tag] - tag ||= stable.version - - if @online - error = SharedAudits.gitlab_release(owner, repo, tag, formula: formula) - problem error if error - end - when %r{^https://github.com/([\w-]+)/([\w-]+)} - owner = Regexp.last_match(1) - repo = Regexp.last_match(2) - tag = SharedAudits.github_tag_from_url(url) - tag ||= formula.stable.specs[:tag] - - if @online - error = SharedAudits.github_release(owner, repo, tag, formula: formula) - problem error if error - end - end - end - - def audit_revision_and_version_scheme - return unless @git - return unless formula.tap # skip formula not from core or any taps - return unless formula.tap.git? # git log is required - return if formula.stable.blank? - - fv = FormulaVersions.new(formula) - - current_version = formula.stable.version - current_checksum = formula.stable.checksum - current_version_scheme = formula.version_scheme - current_revision = formula.revision - current_url = formula.stable.url - - previous_version = nil - previous_version_scheme = nil - previous_revision = nil - - newest_committed_version = nil - newest_committed_checksum = nil - newest_committed_revision = nil - newest_committed_url = nil - - fv.rev_list("origin/master") do |rev| - begin - fv.formula_at_revision(rev) do |f| - stable = f.stable - next if stable.blank? - - previous_version = stable.version - previous_checksum = stable.checksum - previous_version_scheme = f.version_scheme - previous_revision = f.revision - - newest_committed_version ||= previous_version - newest_committed_checksum ||= previous_checksum - newest_committed_revision ||= previous_revision - newest_committed_url ||= stable.url - end - rescue MacOSVersionError - break - end - - break if previous_version && current_version != previous_version - break if previous_revision && current_revision != previous_revision - end - - if current_version == newest_committed_version && - current_url == newest_committed_url && - current_checksum != newest_committed_checksum && - current_checksum.present? && newest_committed_checksum.present? - problem( - "stable sha256 changed without the url/version also changing; " \ - "please create an issue upstream to rule out malicious " \ - "circumstances and to find out why the file changed.", - ) - end - - if !newest_committed_version.nil? && - current_version < newest_committed_version && - current_version_scheme == previous_version_scheme - problem "stable version should not decrease (from #{newest_committed_version} to #{current_version})" - end - - unless previous_version_scheme.nil? - if current_version_scheme < previous_version_scheme - problem "version_scheme should not decrease (from #{previous_version_scheme} " \ - "to #{current_version_scheme})" - elsif current_version_scheme > (previous_version_scheme + 1) - problem "version_schemes should only increment by 1" - end - end - - if (previous_version != newest_committed_version || - current_version != newest_committed_version) && - !current_revision.zero? && - current_revision == newest_committed_revision && - current_revision == previous_revision - problem "'revision #{current_revision}' should be removed" - elsif current_version == previous_version && - !previous_revision.nil? && - current_revision < previous_revision - problem "revision should not decrease (from #{previous_revision} to #{current_revision})" - elsif newest_committed_revision && - current_revision > (newest_committed_revision + 1) - problem "revisions should only increment by 1" - end - end - - def audit_text - bin_names = Set.new - bin_names << formula.name - bin_names += formula.aliases - [formula.bin, formula.sbin].each do |dir| - next unless dir.exist? - - bin_names += dir.children.map(&:basename).map(&:to_s) - end - shell_commands = ["system", "shell_output", "pipe_output"] - bin_names.each do |name| - shell_commands.each do |cmd| - if text.to_s.match?(/test do.*#{cmd}[(\s]+['"]#{Regexp.escape(name)}[\s'"]/m) - problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}") - end - end - end - end - - def audit_reverse_migration - # Only enforce for new formula being re-added to core - return unless @strict - return unless @core_tap - return unless formula.tap.tap_migrations.key?(formula.name) - - problem <<~EOS - #{formula.name} seems to be listed in tap_migrations.json! - Please remove #{formula.name} from present tap & tap_migrations.json - before submitting it to Homebrew/homebrew-#{formula.tap.repo}. - EOS - end - - def audit_prefix_has_contents - return unless formula.prefix.directory? - return unless Keg.new(formula.prefix).empty_installation? - - problem <<~EOS - The installation seems to be empty. Please ensure the prefix - is set correctly and expected files are installed. - The prefix configure/make argument may be case-sensitive. - EOS - end - - def quote_dep(dep) - dep.is_a?(Symbol) ? dep.inspect : "'#{dep}'" - end - - def problem_if_output(output) - problem(output) if output - end - - def audit - only_audits = @only - except_audits = @except - - methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| - name = audit_method_name.delete_prefix("audit_") - if only_audits - next unless only_audits.include?(name) - elsif except_audits - next if except_audits.include?(name) - end - send(audit_method_name) - end - end - - private - - def problem(message, location: nil) - @problems << ({ message: message, location: location }) - end - - def new_formula_problem(message, location: nil) - @new_formula_problems << ({ message: message, location: location }) - end - - def head_only?(formula) - formula.head && formula.stable.nil? - end - - def tap_audit_exception(list, formula, value = nil) - return false unless @tap_audit_exceptions.key? list - - list = @tap_audit_exceptions[list] - - case list - when Array - list.include? formula - when Hash - return false unless list.include? formula - return list[formula] if value.blank? - - list[formula] == value - end - end - end - - class ResourceAuditor - attr_reader :name, :version, :checksum, :url, :mirrors, :using, :specs, :owner, :spec_name, :problems - - def initialize(resource, spec_name, options = {}) - @name = resource.name - @version = resource.version - @checksum = resource.checksum - @url = resource.url - @mirrors = resource.mirrors - @using = resource.using - @specs = resource.specs - @owner = resource.owner - @spec_name = spec_name - @online = options[:online] - @strict = options[:strict] - @problems = [] - end - - def audit - audit_version - audit_download_strategy - audit_urls - self - end - - def audit_version - if version.nil? - problem "missing version" - elsif !version.detected_from_url? - version_text = version - version_url = Version.detect(url, **specs) - if version_url.to_s == version_text.to_s && version.instance_of?(Version) - problem "version #{version_text} is redundant with version scanned from URL" - end - end - end - - def audit_download_strategy - url_strategy = DownloadStrategyDetector.detect(url) - - if (using == :git || url_strategy == GitDownloadStrategy) && specs[:tag] && !specs[:revision] - problem "Git should specify :revision when a :tag is specified." - end - - return unless using - - if using == :cvs - mod = specs[:module] - - problem "Redundant :module value in URL" if mod == name - - if url.match?(%r{:[^/]+$}) - mod = url.split(":").last - - if mod == name - problem "Redundant CVS module appended to URL" - else - problem "Specify CVS module as `:module => \"#{mod}\"` instead of appending it to the URL" - end - end - end - - return unless url_strategy == DownloadStrategyDetector.detect("", using) - - problem "Redundant :using value in URL" - end - - def self.curl_openssl_and_deps - @curl_openssl_and_deps ||= begin - formulae_names = ["curl", "openssl"] - formulae_names += formulae_names.flat_map do |f| - Formula[f].recursive_dependencies.map(&:name) - end - formulae_names.uniq - rescue FormulaUnavailableError - [] - end - end - - def audit_urls - return unless @online - - urls = [url] + mirrors - urls.each do |url| - next if !@strict && mirrors.include?(url) - - strategy = DownloadStrategyDetector.detect(url, using) - if strategy <= CurlDownloadStrategy && !url.start_with?("file") - # A `brew mirror`'ed URL is usually not yet reachable at the time of - # pull request. - next if url.match?(%r{^https://dl.bintray.com/homebrew/mirror/}) - - if http_content_problem = curl_check_http_content(url) - problem http_content_problem - end - elsif strategy <= GitDownloadStrategy - problem "The URL #{url} is not a valid git URL" unless Utils::Git.remote_exists? url - elsif strategy <= SubversionDownloadStrategy - next unless DevelopmentTools.subversion_handles_most_https_certificates? - next unless Utils::Svn.available? - - problem "The URL #{url} is not a valid svn URL" unless Utils::Svn.remote_exists? url - end - end - end - - def problem(text) - @problems << text - end - end end
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/formula_auditor.rb
@@ -0,0 +1,839 @@ +# typed: false +# frozen_string_literal: true + +require "formula_text_auditor" +require "resource_auditor" + +module Homebrew + # Auditor for checking common violations in {Formula}e. + # + # @api private + class FormulaAuditor + include FormulaCellarChecks + + attr_reader :formula, :text, :problems, :new_formula_problems + + def initialize(formula, options = {}) + @formula = formula + @versioned_formula = formula.versioned_formula? + @new_formula_inclusive = options[:new_formula] + @new_formula = options[:new_formula] && !@versioned_formula + @strict = options[:strict] + @online = options[:online] + @build_stable = options[:build_stable] + @git = options[:git] + @display_cop_names = options[:display_cop_names] + @only = options[:only] + @except = options[:except] + # Accept precomputed style offense results, for efficiency + @style_offenses = options[:style_offenses] + # Allow the formula tap to be set as homebrew/core, for testing purposes + @core_tap = formula.tap&.core_tap? || options[:core_tap] + @problems = [] + @new_formula_problems = [] + @text = FormulaTextAuditor.new(formula.path) + @specs = %w[stable head].map { |s| formula.send(s) }.compact + @spdx_license_data = options[:spdx_license_data] + @spdx_exception_data = options[:spdx_exception_data] + @tap_audit_exceptions = options[:tap_audit_exceptions] + end + + def audit_style + return unless @style_offenses + + @style_offenses.each do |offense| + correction_status = "#{Tty.green}[Corrected]#{Tty.reset} " if offense.corrected? + + cop_name = "#{offense.cop_name}: " if @display_cop_names + message = "#{cop_name}#{correction_status}#{offense.message}" + + problem message, location: offense.location + end + end + + def audit_file + if formula.core_formula? && @versioned_formula + unversioned_formula = begin + # build this ourselves as we want e.g. homebrew/core to be present + full_name = if formula.tap + "#{formula.tap}/#{formula.name}" + else + formula.name + end + Formulary.factory(full_name.gsub(/@.*$/, "")).path + rescue FormulaUnavailableError, TapFormulaAmbiguityError, + TapFormulaWithOldnameAmbiguityError + Pathname.new formula.path.to_s.gsub(/@.*\.rb$/, ".rb") + end + unless unversioned_formula.exist? + unversioned_name = unversioned_formula.basename(".rb") + problem "#{formula} is versioned but no #{unversioned_name} formula exists" + end + elsif @build_stable && + formula.stable? && + !@versioned_formula && + (versioned_formulae = formula.versioned_formulae - [formula]) && + versioned_formulae.present? + versioned_aliases = formula.aliases.grep(/.@\d/) + _, last_alias_version = versioned_formulae.map(&:name).last.split("@") + alias_name_major = "#{formula.name}@#{formula.version.major}" + alias_name_major_minor = "#{alias_name_major}.#{formula.version.minor}" + alias_name = if last_alias_version.split(".").length == 1 + alias_name_major + else + alias_name_major_minor + end + valid_alias_names = [alias_name_major, alias_name_major_minor] + + unless @core_tap + versioned_aliases.map! { |a| "#{formula.tap}/#{a}" } + valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } + end + + # Fix naming based on what people expect. + if alias_name_major_minor == "adoptopenjdk@1.8" + valid_alias_names << "adoptopenjdk@8" + valid_alias_names.delete "adoptopenjdk@1" + end + + valid_versioned_aliases = versioned_aliases & valid_alias_names + invalid_versioned_aliases = versioned_aliases - valid_alias_names + + if valid_versioned_aliases.empty? + if formula.tap + problem <<~EOS + Formula has other versions so create a versioned alias: + cd #{formula.tap.alias_dir} + ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name} + EOS + else + problem "Formula has other versions so create an alias named #{alias_name}." + end + end + + if invalid_versioned_aliases.present? + problem <<~EOS + Formula has invalid versioned aliases: + #{invalid_versioned_aliases.join("\n ")} + EOS + end + end + end + + def self.aliases + # core aliases + tap alias names + tap alias full name + @aliases ||= Formula.aliases + Formula.tap_aliases + end + + def audit_formula_name + return unless @strict + return unless @core_tap + + name = formula.name + + problem "'#{name}' is not allowed in homebrew/core." if MissingFormula.disallowed_reason(name) + + if Formula.aliases.include? name + problem "Formula name conflicts with existing aliases in homebrew/core." + return + end + + if oldname = CoreTap.instance.formula_renames[name] + problem "'#{name}' is reserved as the old name of #{oldname} in homebrew/core." + return + end + + return if formula.core_formula? + return unless Formula.core_names.include?(name) + + problem "Formula name conflicts with existing core formula." + end + + PROVIDED_BY_MACOS_DEPENDS_ON_ALLOWLIST = %w[ + apr + apr-util + libressl + openblas + openssl@1.1 + ].freeze + + PERMITTED_LICENSE_MISMATCHES = { + "AGPL-3.0" => ["AGPL-3.0-only", "AGPL-3.0-or-later"], + "GPL-2.0" => ["GPL-2.0-only", "GPL-2.0-or-later"], + "GPL-3.0" => ["GPL-3.0-only", "GPL-3.0-or-later"], + "LGPL-2.1" => ["LGPL-2.1-only", "LGPL-2.1-or-later"], + "LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"], + }.freeze + + PERMITTED_FORMULA_LICENSE_MISMATCHES = { + "cmockery" => "0.1.2", + "scw@1" => "1.20", + }.freeze + + def audit_license + if formula.license.present? + licenses, exceptions = SPDX.parse_license_expression formula.license + + non_standard_licenses = licenses.reject { |license| SPDX.valid_license? license } + if non_standard_licenses.present? + problem <<~EOS + Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}. + For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} + EOS + end + + if @strict + deprecated_licenses = licenses.select do |license| + SPDX.deprecated_license? license + end + if deprecated_licenses.present? + problem <<~EOS + Formula #{formula.name} contains deprecated SPDX licenses: #{deprecated_licenses}. + You may need to add `-only` or `-or-later` for GNU licenses (e.g. `GPL`, `LGPL`, `AGPL`, `GFDL`). + For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} + EOS + end + end + + invalid_exceptions = exceptions.reject { |exception| SPDX.valid_license_exception? exception } + if invalid_exceptions.present? + problem <<~EOS + Formula #{formula.name} contains invalid or deprecated SPDX license exceptions: #{invalid_exceptions}. + For a list of valid license exceptions check: + #{Formatter.url("https://spdx.org/licenses/exceptions-index.html")} + EOS + end + + return unless @online + + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) + return if user.blank? + + github_license = GitHub.get_repo_license(user, repo) + return unless github_license + return if (licenses + ["NOASSERTION"]).include?(github_license) + return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license } + return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version + + problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}." + + elsif @new_formula && @core_tap + problem "Formulae in homebrew/core must specify a license." + end + end + + # TODO: try to remove these, it's not a good user experience + VERSIONED_DEPENDENCIES_CONFLICTS_ALLOWLIST = %w[ + agda + anjuta + fdroidserver + gradio + predictionio + sqoop + visp + ].freeze + + def audit_deps + @specs.each do |spec| + # Check for things we don't like to depend on. + # We allow non-Homebrew installs whenever possible. + spec.deps.each do |dep| + begin + dep_f = dep.to_formula + rescue TapFormulaUnavailableError + # Don't complain about missing cross-tap dependencies + next + rescue FormulaUnavailableError + problem "Can't find dependency #{dep.name.inspect}." + next + rescue TapFormulaAmbiguityError + problem "Ambiguous dependency #{dep.name.inspect}." + next + rescue TapFormulaWithOldnameAmbiguityError + problem "Ambiguous oldname dependency #{dep.name.inspect}." + next + end + + if dep_f.oldname && dep.name.split("/").last == dep_f.oldname + problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'." + end + + if self.class.aliases.include?(dep.name) && + dep_f.core_formula? && !dep_f.versioned_formula? + problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \ + "use the canonical name '#{dep.to_formula.full_name}'." + end + + if @core_tap && + @new_formula && + dep_f.keg_only? && + dep_f.keg_only_reason.provided_by_macos? && + dep_f.keg_only_reason.applicable? && + !PROVIDED_BY_MACOS_DEPENDS_ON_ALLOWLIST.include?(dep.name) + new_formula_problem( + "Dependency '#{dep.name}' is provided by macOS; " \ + "please replace 'depends_on' with 'uses_from_macos'.", + ) + end + + dep.options.each do |opt| + next if @core_tap + next if dep_f.option_defined?(opt) + next if dep_f.requirements.find do |r| + if r.recommended? + opt.name == "with-#{r.name}" + elsif r.optional? + opt.name == "without-#{r.name}" + end + end + + problem "Dependency #{dep} does not define option #{opt.name.inspect}" + end + + problem "Don't use git as a dependency (it's always available)" if @new_formula && dep.name == "git" + + problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run) + + next unless @core_tap + + if dep.tags.include?(:recommended) || dep.tags.include?(:optional) + problem "Formulae in homebrew/core should not have optional or recommended dependencies" + end + end + + next unless @core_tap + + if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any? + problem "Formulae in homebrew/core should not have optional or recommended requirements" + end + end + + return unless @core_tap + return if VERSIONED_DEPENDENCIES_CONFLICTS_ALLOWLIST.include?(formula.name) + + # The number of conflicts on Linux is absurd. + # TODO: remove this and check these there too. + return if OS.linux? + + recursive_runtime_formulae = formula.runtime_formula_dependencies(undeclared: false) + version_hash = {} + version_conflicts = Set.new + recursive_runtime_formulae.each do |f| + name = f.name + unversioned_name, = name.split("@") + version_hash[unversioned_name] ||= Set.new + version_hash[unversioned_name] << name + next if version_hash[unversioned_name].length < 2 + + version_conflicts += version_hash[unversioned_name] + end + + return if version_conflicts.empty? + + problem <<~EOS + #{formula.full_name} contains conflicting version recursive dependencies: + #{version_conflicts.to_a.join ", "} + View these with `brew deps --tree #{formula.full_name}`. + EOS + end + + def audit_conflicts + formula.conflicts.each do |c| + Formulary.factory(c.name) + rescue TapFormulaUnavailableError + # Don't complain about missing cross-tap conflicts. + next + rescue FormulaUnavailableError + problem "Can't find conflicting formula #{c.name.inspect}." + rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError + problem "Ambiguous conflicting formula #{c.name.inspect}." + end + end + + def audit_postgresql + return unless formula.name == "postgresql" + return unless @core_tap + + major_version = formula.version.major.to_i + previous_major_version = major_version - 1 + previous_formula_name = "postgresql@#{previous_major_version}" + begin + Formula[previous_formula_name] + rescue FormulaUnavailableError + problem "Versioned #{previous_formula_name} in homebrew/core must be created for " \ + "`brew-postgresql-upgrade-database` and `pg_upgrade` to work." + end + end + + # openssl@1.1 only needed for Linux + VERSIONED_KEG_ONLY_ALLOWLIST = %w[ + autoconf@2.13 + bash-completion@2 + clang-format@8 + gnupg@1.4 + libsigc++@2 + lua@5.1 + numpy@1.16 + openssl@1.1 + python@3.8 + python@3.9 + ].freeze + + def audit_versioned_keg_only + return unless @versioned_formula + return unless @core_tap + + if formula.keg_only? + return if formula.keg_only_reason.versioned_formula? + if formula.name.start_with?("openssl", "libressl") && + formula.keg_only_reason.by_macos? + return + end + end + + return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name) + return if formula.name.start_with?("adoptopenjdk@") + return if formula.name.start_with?("gcc@") + + problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`" + end + + CERT_ERROR_ALLOWLIST = { + "hashcat" => "https://hashcat.net/hashcat/", + "jinx" => "https://www.jinx-lang.org/", + "lmod" => "https://www.tacc.utexas.edu/research-development/tacc-projects/lmod", + "micropython" => "https://www.micropython.org/", + "monero" => "https://www.getmonero.org/", + }.freeze + + def audit_homepage + homepage = formula.homepage + + return if homepage.nil? || homepage.empty? + + return unless @online + + return if CERT_ERROR_ALLOWLIST[formula.name] == homepage + + return unless DevelopmentTools.curl_handles_most_https_certificates? + + if http_content_problem = curl_check_http_content(homepage, + user_agents: [:browser, :default], + check_content: true, + strict: @strict) + problem http_content_problem + end + end + + def audit_bottle_spec + # special case: new versioned formulae should be audited + return unless @new_formula_inclusive + return unless @core_tap + + return if formula.bottle_disabled? + + return unless formula.bottle_defined? + + new_formula_problem "New formulae in homebrew/core should not have a `bottle do` block" + end + + def audit_bottle_disabled + return unless formula.bottle_disabled? + return if formula.bottle_unneeded? + + problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid? + + return unless @core_tap + + problem "Formulae in homebrew/core should not use `bottle :disabled`" + end + + def audit_github_repository_archived + return if formula.deprecated? + + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @online + return if user.blank? + + metadata = SharedAudits.github_repo_data(user, repo) + return if metadata.nil? + + problem "GitHub repo is archived" if metadata["archived"] + end + + def audit_gitlab_repository_archived + return if formula.deprecated? + + user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if @online + return if user.blank? + + metadata = SharedAudits.gitlab_repo_data(user, repo) + return if metadata.nil? + + problem "GitLab repo is archived" if metadata["archived"] + end + + def audit_github_repository + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula + + return if user.blank? + + warning = SharedAudits.github(user, repo) + return if warning.nil? + + new_formula_problem warning + end + + def audit_gitlab_repository + user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if @new_formula + return if user.blank? + + warning = SharedAudits.gitlab(user, repo) + return if warning.nil? + + new_formula_problem warning + end + + def audit_bitbucket_repository + user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*}) if @new_formula + return if user.blank? + + warning = SharedAudits.bitbucket(user, repo) + return if warning.nil? + + new_formula_problem warning + end + + def get_repo_data(regex) + return unless @core_tap + return unless @online + + _, user, repo = *regex.match(formula.stable.url) if formula.stable + _, user, repo = *regex.match(formula.homepage) unless user + _, user, repo = *regex.match(formula.head.url) if !user && formula.head + return if !user || !repo + + repo.delete_suffix!(".git") + + [user, repo] + end + + UNSTABLE_ALLOWLIST = { + "aalib" => "1.4rc", + "automysqlbackup" => "3.0-rc", + "aview" => "1.3.0rc", + "elm-format" => "0.6.0-alpha", + "ftgl" => "2.1.3-rc", + "hidapi" => "0.8.0-rc", + "libcaca" => "0.99b", + "premake" => "4.4-beta", + "pwnat" => "0.3-beta", + "recode" => "3.7-beta", + "speexdsp" => "1.2rc", + "sqoop" => "1.4.", + "tcptraceroute" => "1.5beta", + "tiny-fugue" => "5.0b", + "vbindiff" => "3.0_beta", + }.freeze + + # Used for formulae that are unstable but need CI run without being in homebrew/core + UNSTABLE_DEVEL_ALLOWLIST = { + }.freeze + + GNOME_DEVEL_ALLOWLIST = { + "libart" => "2.3", + "gtk-mac-integration" => "2.1", + "gtk-doc" => "1.31", + "gcab" => "1.3", + "libepoxy" => "1.5", + }.freeze + + def audit_specs + problem "Head-only (no stable download)" if head_only?(formula) + + %w[Stable HEAD].each do |name| + spec_name = name.downcase.to_sym + next unless spec = formula.send(spec_name) + + ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit + ra.problems.each do |message| + problem "#{name}: #{message}" + end + + spec.resources.each_value do |resource| + problem "Resource name should be different from the formula name" if resource.name == formula.name + + ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit + ra.problems.each do |message| + problem "#{name} resource #{resource.name.inspect}: #{message}" + end + end + + next if spec.patches.empty? + next unless @new_formula + + new_formula_problem( + "Formulae should not require patches to build. " \ + "Patches should be submitted and accepted upstream first.", + ) + end + + if stable = formula.stable + version = stable.version + problem "Stable: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/ + if version.to_s.start_with?("HEAD") + problem "Stable: non-HEAD version name (#{version}) should not begin with HEAD" + end + end + + return unless @core_tap + + if formula.head && @versioned_formula && + !tap_audit_exception(:versioned_head_spec_allowlist, formula.name) + problem "Versioned formulae should not have a `HEAD` spec" + end + + stable = formula.stable + return unless stable + return unless stable.url + + stable_version_string = stable.version.to_s + stable_url_version = Version.parse(stable.url) + stable_url_minor_version = stable_url_version.minor.to_i + + formula_suffix = stable.version.patch.to_i + throttled_rate = tap_audit_exception(:throttled_formulae, formula.name) + if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? + problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" + end + + case (url = stable.url) + when /[\d._-](alpha|beta|rc\d)/ + matched = Regexp.last_match(1) + version_prefix = stable_version_string.sub(/\d+$/, "") + return if UNSTABLE_ALLOWLIST[formula.name] == version_prefix + return if UNSTABLE_DEVEL_ALLOWLIST[formula.name] == version_prefix + + problem "Stable version URLs should not contain #{matched}" + when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i + version_prefix = stable.version.major_minor + return if GNOME_DEVEL_ALLOWLIST[formula.name] == version_prefix + return if stable_url_version < Version.create("1.0") + return if stable_url_minor_version.even? + + problem "#{stable.version} is a development release" + when %r{isc.org/isc/bind\d*/}i + return if stable_url_minor_version.even? + + problem "#{stable.version} is a development release" + + when %r{https?://gitlab\.com/([\w-]+)/([\w-]+)} + owner = Regexp.last_match(1) + repo = Regexp.last_match(2) + + tag = SharedAudits.gitlab_tag_from_url(url) + tag ||= stable.specs[:tag] + tag ||= stable.version + + if @online + error = SharedAudits.gitlab_release(owner, repo, tag, formula: formula) + problem error if error + end + when %r{^https://github.com/([\w-]+)/([\w-]+)} + owner = Regexp.last_match(1) + repo = Regexp.last_match(2) + tag = SharedAudits.github_tag_from_url(url) + tag ||= formula.stable.specs[:tag] + + if @online + error = SharedAudits.github_release(owner, repo, tag, formula: formula) + problem error if error + end + end + end + + def audit_revision_and_version_scheme + return unless @git + return unless formula.tap # skip formula not from core or any taps + return unless formula.tap.git? # git log is required + return if formula.stable.blank? + + fv = FormulaVersions.new(formula) + + current_version = formula.stable.version + current_checksum = formula.stable.checksum + current_version_scheme = formula.version_scheme + current_revision = formula.revision + current_url = formula.stable.url + + previous_version = nil + previous_version_scheme = nil + previous_revision = nil + + newest_committed_version = nil + newest_committed_checksum = nil + newest_committed_revision = nil + newest_committed_url = nil + + fv.rev_list("origin/master") do |rev| + begin + fv.formula_at_revision(rev) do |f| + stable = f.stable + next if stable.blank? + + previous_version = stable.version + previous_checksum = stable.checksum + previous_version_scheme = f.version_scheme + previous_revision = f.revision + + newest_committed_version ||= previous_version + newest_committed_checksum ||= previous_checksum + newest_committed_revision ||= previous_revision + newest_committed_url ||= stable.url + end + rescue MacOSVersionError + break + end + + break if previous_version && current_version != previous_version + break if previous_revision && current_revision != previous_revision + end + + if current_version == newest_committed_version && + current_url == newest_committed_url && + current_checksum != newest_committed_checksum && + current_checksum.present? && newest_committed_checksum.present? + problem( + "stable sha256 changed without the url/version also changing; " \ + "please create an issue upstream to rule out malicious " \ + "circumstances and to find out why the file changed.", + ) + end + + if !newest_committed_version.nil? && + current_version < newest_committed_version && + current_version_scheme == previous_version_scheme + problem "stable version should not decrease (from #{newest_committed_version} to #{current_version})" + end + + unless previous_version_scheme.nil? + if current_version_scheme < previous_version_scheme + problem "version_scheme should not decrease (from #{previous_version_scheme} " \ + "to #{current_version_scheme})" + elsif current_version_scheme > (previous_version_scheme + 1) + problem "version_schemes should only increment by 1" + end + end + + if (previous_version != newest_committed_version || + current_version != newest_committed_version) && + !current_revision.zero? && + current_revision == newest_committed_revision && + current_revision == previous_revision + problem "'revision #{current_revision}' should be removed" + elsif current_version == previous_version && + !previous_revision.nil? && + current_revision < previous_revision + problem "revision should not decrease (from #{previous_revision} to #{current_revision})" + elsif newest_committed_revision && + current_revision > (newest_committed_revision + 1) + problem "revisions should only increment by 1" + end + end + + def audit_text + bin_names = Set.new + bin_names << formula.name + bin_names += formula.aliases + [formula.bin, formula.sbin].each do |dir| + next unless dir.exist? + + bin_names += dir.children.map(&:basename).map(&:to_s) + end + shell_commands = ["system", "shell_output", "pipe_output"] + bin_names.each do |name| + shell_commands.each do |cmd| + if text.to_s.match?(/test do.*#{cmd}[(\s]+['"]#{Regexp.escape(name)}[\s'"]/m) + problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}") + end + end + end + end + + def audit_reverse_migration + # Only enforce for new formula being re-added to core + return unless @strict + return unless @core_tap + return unless formula.tap.tap_migrations.key?(formula.name) + + problem <<~EOS + #{formula.name} seems to be listed in tap_migrations.json! + Please remove #{formula.name} from present tap & tap_migrations.json + before submitting it to Homebrew/homebrew-#{formula.tap.repo}. + EOS + end + + def audit_prefix_has_contents + return unless formula.prefix.directory? + return unless Keg.new(formula.prefix).empty_installation? + + problem <<~EOS + The installation seems to be empty. Please ensure the prefix + is set correctly and expected files are installed. + The prefix configure/make argument may be case-sensitive. + EOS + end + + def quote_dep(dep) + dep.is_a?(Symbol) ? dep.inspect : "'#{dep}'" + end + + def problem_if_output(output) + problem(output) if output + end + + def audit + only_audits = @only + except_audits = @except + + methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| + name = audit_method_name.delete_prefix("audit_") + if only_audits + next unless only_audits.include?(name) + elsif except_audits + next if except_audits.include?(name) + end + send(audit_method_name) + end + end + + private + + def problem(message, location: nil) + @problems << ({ message: message, location: location }) + end + + def new_formula_problem(message, location: nil) + @new_formula_problems << ({ message: message, location: location }) + end + + def head_only?(formula) + formula.head && formula.stable.nil? + end + + def tap_audit_exception(list, formula, value = nil) + return false unless @tap_audit_exceptions.key? list + + list = @tap_audit_exceptions[list] + + case list + when Array + list.include? formula + when Hash + return false unless list.include? formula + return list[formula] if value.blank? + + list[formula] == value + end + end + end +end
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/formula_text_auditor.rb
@@ -0,0 +1,40 @@ +# typed: false +# frozen_string_literal: true + +module Homebrew + # Auditor for checking common violations in {Formula} text content. + # + # @api private + class FormulaTextAuditor + def initialize(path) + @text = path.open("rb", &:read) + @lines = @text.lines.to_a + end + + def without_patch + @text.split("\n__END__").first + end + + def trailing_newline? + /\Z\n/ =~ @text + end + + def =~(other) + other =~ @text + end + + def include?(s) + @text.include? s + end + + def line_number(regex, skip = 0) + index = @lines.drop(skip).index { |line| line =~ regex } + index ? index + 1 : nil + end + + def reverse_line_number(regex) + index = @lines.reverse.index { |line| line =~ regex } + index ? @lines.count - index : nil + end + end +end
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/resource_auditor.rb
@@ -0,0 +1,118 @@ +# typed: false +# frozen_string_literal: true + +module Homebrew + # Auditor for checking common violations in {Resource}s. + # + # @api private + class ResourceAuditor + attr_reader :name, :version, :checksum, :url, :mirrors, :using, :specs, :owner, :spec_name, :problems + + def initialize(resource, spec_name, options = {}) + @name = resource.name + @version = resource.version + @checksum = resource.checksum + @url = resource.url + @mirrors = resource.mirrors + @using = resource.using + @specs = resource.specs + @owner = resource.owner + @spec_name = spec_name + @online = options[:online] + @strict = options[:strict] + @problems = [] + end + + def audit + audit_version + audit_download_strategy + audit_urls + self + end + + def audit_version + if version.nil? + problem "missing version" + elsif !version.detected_from_url? + version_text = version + version_url = Version.detect(url, **specs) + if version_url.to_s == version_text.to_s && version.instance_of?(Version) + problem "version #{version_text} is redundant with version scanned from URL" + end + end + end + + def audit_download_strategy + url_strategy = DownloadStrategyDetector.detect(url) + + if (using == :git || url_strategy == GitDownloadStrategy) && specs[:tag] && !specs[:revision] + problem "Git should specify :revision when a :tag is specified." + end + + return unless using + + if using == :cvs + mod = specs[:module] + + problem "Redundant :module value in URL" if mod == name + + if url.match?(%r{:[^/]+$}) + mod = url.split(":").last + + if mod == name + problem "Redundant CVS module appended to URL" + else + problem "Specify CVS module as `:module => \"#{mod}\"` instead of appending it to the URL" + end + end + end + + return unless url_strategy == DownloadStrategyDetector.detect("", using) + + problem "Redundant :using value in URL" + end + + def self.curl_openssl_and_deps + @curl_openssl_and_deps ||= begin + formulae_names = ["curl", "openssl"] + formulae_names += formulae_names.flat_map do |f| + Formula[f].recursive_dependencies.map(&:name) + end + formulae_names.uniq + rescue FormulaUnavailableError + [] + end + end + + def audit_urls + return unless @online + + urls = [url] + mirrors + urls.each do |url| + next if !@strict && mirrors.include?(url) + + strategy = DownloadStrategyDetector.detect(url, using) + if strategy <= CurlDownloadStrategy && !url.start_with?("file") + # A `brew mirror`'ed URL is usually not yet reachable at the time of + # pull request. + next if url.match?(%r{^https://dl.bintray.com/homebrew/mirror/}) + + if http_content_problem = curl_check_http_content(url) + problem http_content_problem + end + elsif strategy <= GitDownloadStrategy + problem "The URL #{url} is not a valid git URL" unless Utils::Git.remote_exists? url + elsif strategy <= SubversionDownloadStrategy + next unless DevelopmentTools.subversion_handles_most_https_certificates? + next unless Utils::Svn.available? + + problem "The URL #{url} is not a valid svn URL" unless Utils::Svn.remote_exists? url + end + end + end + + def problem(text) + @problems << text + end + end +end
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/tap_auditor.rb
@@ -2,7 +2,7 @@ # frozen_string_literal: true module Homebrew - # Auditor for checking common violations in taps. + # Auditor for checking common violations in {Tap}s. # # @api private class TapAuditor
true
Other
Homebrew
brew
dc11f02e16a223098f0ffc087764fe24c34ce973.json
Move auditor classes into separate files.
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -18,7 +18,7 @@ def self.increment end module Homebrew - describe FormulaText do + describe FormulaTextAuditor do alias_matcher :have_data, :be_data alias_matcher :have_end, :be_end alias_matcher :have_trailing_newline, :be_trailing_newline
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
Library/Homebrew/cli/parser.rb
@@ -100,7 +100,7 @@ def self.global_cask_options def self.global_options [ ["-d", "--debug", "Display any debugging information."], - ["-q", "--quiet", "Suppress any warnings."], + ["-q", "--quiet", "Make some output more quiet."], ["-v", "--verbose", "Make some output more verbose."], ["-h", "--help", "Show this message."], ]
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
Library/Homebrew/cmd/install.rb
@@ -204,7 +204,7 @@ def install EOS elsif args.only_dependencies? installed_formulae << f - else + elsif !args.quiet? opoo <<~EOS #{f.full_name} #{f.pkg_version} is already installed and up-to-date To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}` @@ -224,11 +224,14 @@ def install msg = "#{f.full_name} #{installed_version} is already installed" linked_not_equals_installed = f.linked_version != installed_version if f.linked? && linked_not_equals_installed - msg = <<~EOS - #{msg} - The currently linked version is #{f.linked_version} - You can use `brew switch #{f} #{installed_version}` to link this version. - EOS + msg = if args.quiet? + nil + else + <<~EOS + #{msg} + The currently linked version is #{f.linked_version} + EOS + end elsif !f.linked? || f.keg_only? msg = <<~EOS #{msg}, it's just not linked @@ -238,10 +241,14 @@ def install msg = nil installed_formulae << f else - msg = <<~EOS - #{msg} and up-to-date - To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}` - EOS + msg = if args.quiet? + nil + else + <<~EOS + #{msg} and up-to-date + To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}` + EOS + end end opoo msg if msg elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first @@ -251,8 +258,10 @@ def install #{msg}, it's just not linked. You can use `brew link #{old_formula.full_name}` to link this version. EOS + elsif args.quiet? + msg = nil end - opoo msg + opoo msg if msg elsif f.migration_needed? && !args.force? # Check if the formula we try to install is the same as installed # but not migrated one. If --force is passed then install anyway.
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
Library/Homebrew/dev-cmd/diy.rb
@@ -31,6 +31,8 @@ def diy_args def diy args = diy_args.parse + # odeprecated "`brew diy`" + path = Pathname.getwd version = args.version || detect_version(path)
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
docs/Manpage.md
@@ -1384,7 +1384,7 @@ These options are applicable across multiple subcommands. Display any debugging information. * `-q`, `--quiet`: - Suppress any warnings. + Make some output more quiet. * `-v`, `--verbose`: Make some output more verbose.
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
docs/Tips-N'-Tricks.md
@@ -15,15 +15,6 @@ This can be useful if a package can't build against the version of something you And of course, you can simply `brew link <formula>` again afterwards! -## Activate a previously installed version of a formula - -```sh -brew info <formula> -brew switch <formula> <version> -``` - -Use `brew info <formula>` to check what versions are installed but not currently activated, then `brew switch <formula> <version>` to activate the desired version. This can be useful if you would like to switch between versions of a formula. - ## Install into Homebrew without formulae ```sh
true
Other
Homebrew
brew
caae165eb20f5876ca2edf3f16cc7caba6cf479c.json
Improve `brew install --quiet` - Suppress (some more) warnings when doing `brew install --quiet` - Clarify `man brew` output that we don't suppress all warnings for all commands with `--quiet` While I was doing this I noticed references to the (soon to be deprecated) `brew switch` so: - remove these references in `install` output - remove a reference in the documentation - add a comment to remind me to deprecate `brew diy`, too Fixes #9179
manpages/brew.1
@@ -1899,7 +1899,7 @@ Display any debugging information\. . .TP \fB\-q\fR, \fB\-\-quiet\fR -Suppress any warnings\. +Make some output more quiet\. . .TP \fB\-v\fR, \fB\-\-verbose\fR
true
Other
Homebrew
brew
bcdb0c769888dc1af4b4074fd237e98478779880.json
upgrade: show upgradeable dependents during dry run
Library/Homebrew/cmd/install.rb
@@ -289,7 +289,7 @@ def install Cleanup.install_formula_clean!(f) end - Upgrade.check_installed_dependents(args: args) + Upgrade.check_installed_dependents(installed_formulae, args: args) Homebrew.messages.display_messages(display_times: args.display_times?) rescue FormulaUnreadableError, FormulaClassUnavailableError,
true
Other
Homebrew
brew
bcdb0c769888dc1af4b4074fd237e98478779880.json
upgrade: show upgradeable dependents during dry run
Library/Homebrew/cmd/reinstall.rb
@@ -102,7 +102,7 @@ def reinstall Cleanup.install_formula_clean!(f) end - Upgrade.check_installed_dependents(args: args) + Upgrade.check_installed_dependents(formulae, args: args) if casks.any? Cask::Cmd::Reinstall.reinstall_casks(
true
Other
Homebrew
brew
bcdb0c769888dc1af4b4074fd237e98478779880.json
upgrade: show upgradeable dependents during dry run
Library/Homebrew/cmd/upgrade.rb
@@ -172,7 +172,7 @@ def upgrade_outdated_formulae(formulae, args:) Upgrade.upgrade_formulae(formulae_to_install, args: args) - Upgrade.check_installed_dependents(args: args) + Upgrade.check_installed_dependents(formulae_to_install, args: args) Homebrew.messages.display_messages(display_times: args.display_times?) end
true
Other
Homebrew
brew
bcdb0c769888dc1af4b4074fd237e98478779880.json
upgrade: show upgradeable dependents during dry run
Library/Homebrew/upgrade.rb
@@ -134,10 +134,10 @@ def check_broken_dependents(installed_formulae) end end - def check_installed_dependents(args:) + def check_installed_dependents(formulae, args:) return if Homebrew::EnvConfig.no_installed_dependents_check? - installed_formulae = FormulaInstaller.installed.to_a + installed_formulae = args.dry_run? ? formulae : FormulaInstaller.installed.to_a return if installed_formulae.empty? already_broken_dependents = check_broken_dependents(installed_formulae)
true
Other
Homebrew
brew
42881ebc55dca3e2bf04d91ebb737b546cb9c5eb.json
shared_audits: add haptickey to GITHUB_PRERELEASE_ALLOWLIST
Library/Homebrew/utils/shared_audits.rb
@@ -37,6 +37,7 @@ def github_release_data(user, repo, tag) "extraterm" => :all, "freetube" => :all, "gitless" => "0.8.8", + "haptickey" => :all, "home-assistant" => :all, "lidarr" => :all, "nuclear" => :all,
false
Other
Homebrew
brew
362c64855c623c5e059fff11da4d234cc69e50f8.json
unpack_strategy: Move `Dmg` to above `Xz` and `Lzma`
Library/Homebrew/unpack_strategy.rb
@@ -47,6 +47,7 @@ def self.strategies Tar, # Needs to be before Bzip2/Gzip/Xz/Lzma. Pax, Gzip, + Dmg, # Needs to be before Bzip2/Xz/Lzma. Lzma, Xz, Lzip, @@ -66,7 +67,6 @@ def self.strategies SelfExtractingExecutable, # Needs to be before `Cab`. Cab, Executable, - Dmg, # Needs to be before `Bzip2`. Bzip2, Fossil, Bazaar,
false