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
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/cask/cmd/create.rb
@@ -30,6 +30,7 @@ def self.template(cask_token) url "https://" name "" + desc "" homepage "" app ""
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/cask/dsl.rb
@@ -64,6 +64,7 @@ class DSL :caveats, :conflicts_with, :container, + :desc, :depends_on, :homepage, :language, @@ -93,6 +94,10 @@ def name(*args) @name.concat(args.flatten) end + def desc(description = nil) + set_unique_stanza(:desc, description.nil?) { description } + end + def set_unique_stanza(stanza, should_return) return instance_variable_get("@#{stanza}") if should_return
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/rubocops/cask/constants/stanza.rb
@@ -6,7 +6,7 @@ module Cask module Constants STANZA_GROUPS = [ [:version, :sha256], - [:url, :appcast, :name, :homepage], + [:url, :appcast, :desc, :name, :homepage], [ :auto_updates, :conflicts_with,
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/test/cask/cmd/create_spec.rb
@@ -35,6 +35,7 @@ url "https://" name "" + desc "" homepage "" app ""
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/test/cask/cmd/list_spec.rb
@@ -90,7 +90,7 @@ let(:casks) { ["local-caffeine", "local-transmission"] } let(:expected_output) { <<~EOS - [{"token":"local-caffeine","name":[],"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/caffeine.zip","appcast":null,"version":"1.2.3","sha256":"67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94","artifacts":[["Caffeine.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null},{"token":"local-transmission","name":["Transmission"],"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/transmission-2.61.dmg","appcast":null,"version":"2.61","sha256":"e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68","artifacts":[["Transmission.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null}] + [{"token":"local-caffeine","name":[],"desc":null,"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/caffeine.zip","appcast":null,"version":"1.2.3","sha256":"67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94","artifacts":[["Caffeine.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null},{"token":"local-transmission","name":["Transmission"],"desc":null,"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/transmission-2.61.dmg","appcast":null,"version":"2.61","sha256":"e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68","artifacts":[["Transmission.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null}] EOS }
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/test/cask/dsl_spec.rb
@@ -107,6 +107,16 @@ end end + describe "desc stanza" do + it "lets you set the description via a desc stanza" do + cask = Cask::Cask.new("desc-cask") do + desc "The package's description" + end + + expect(cask.desc).to eq("The package's description") + end + end + describe "sha256 stanza" do it "lets you set checksum via sha256" do cask = Cask::Cask.new("checksum-cask") do
true
Other
Homebrew
brew
53ebef4c675f70a324ee0d8e2c7146801ce14b3a.json
Gemfile: drop sorbet environment
Library/Homebrew/Gemfile
@@ -13,11 +13,9 @@ gem "rspec-retry", require: false gem "rspec-wait", require: false gem "rubocop" gem "simplecov", require: false -if ENV["HOMEBREW_SORBET"] - gem "sorbet", "0.5.5823" - gem "sorbet-runtime", "0.5.5823" - gem "tapioca" -end +gem "sorbet", "0.5.5823" +gem "sorbet-runtime", "0.5.5823" +gem "tapioca" # vendored gems gem "activesupport"
true
Other
Homebrew
brew
53ebef4c675f70a324ee0d8e2c7146801ce14b3a.json
Gemfile: drop sorbet environment
Library/Homebrew/Gemfile.lock
@@ -14,7 +14,10 @@ GEM colorize json simplecov + coderay (1.1.3) colorize (0.8.1) + commander (4.5.2) + highline (~> 2.0.0) concurrent-ruby (1.1.6) connection_pool (2.2.3) diff-lcs (1.4.4) @@ -23,6 +26,7 @@ GEM unf (>= 0.0.5, < 1.0.0) elftools (1.1.2) bindata (~> 2) + highline (2.0.3) hpricot (0.8.6) http-cookie (1.0.3) domain_name (~> 0.5) @@ -38,6 +42,7 @@ GEM nokogiri (~> 1.6) ntlm-http (~> 0.1, >= 0.1.1) webrobots (>= 0.0.9, < 0.2) + method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2020.0512) @@ -53,11 +58,19 @@ GEM parallel (1.19.2) parallel_tests (3.1.0) parallel + parlour (4.0.1) + commander (~> 4.5) + parser + rainbow (~> 3.0) + sorbet-runtime (>= 0.5) parser (2.7.1.4) ast (~> 2.4.1) patchelf (1.2.0) elftools (~> 1.1) plist (3.5.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rainbow (3.0.0) rdiscount (2.2.0.1) regexp_parser (1.7.1) @@ -107,6 +120,17 @@ GEM docile (~> 1.1) simplecov-html (~> 0.11) simplecov-html (0.12.2) + sorbet (0.5.5823) + sorbet-static (= 0.5.5823) + sorbet-runtime (0.5.5823) + sorbet-static (0.5.5823-universal-darwin-14) + tapioca (0.4.1) + parlour (>= 2.1.0) + pry (>= 0.12.2) + sorbet-runtime + sorbet-static (>= 0.4.4471) + thor (>= 0.19.2) + thor (1.0.1) thread_safe (0.3.6) tzinfo (1.2.7) thread_safe (~> 0.1) @@ -139,6 +163,9 @@ DEPENDENCIES rubocop-rspec ruby-macho simplecov + sorbet (= 0.5.5823) + sorbet-runtime (= 0.5.5823) + tapioca BUNDLED WITH 1.17.3
true
Other
Homebrew
brew
05b3518b0cb3dac595531014326858016a622ae2.json
Improve documentation comments for Livecheck DSL
Library/Homebrew/livecheck.rb
@@ -1,13 +1,15 @@ # frozen_string_literal: true -# Livecheck can be used to check for newer versions of the software. -# The livecheck DSL specified in the formula is evaluated the methods -# of this class, which set the instance variables accordingly. The -# information is used by brew livecheck when checking for newer versions -# of the software. +# The `Livecheck` class implements the DSL methods used in a formula's +# `livecheck` block and stores related instance variables. Most of these methods +# also return the related instance variable when no argument is provided. +# +# This information is used by the `brew livecheck` command to control its +# behavior. class Livecheck - # The reason for skipping livecheck for the formula. - # e.g. `Not maintained` + # A very brief description of why the formula is skipped (e.g., `No longer + # developed or maintained`). + # @return [String, nil] attr_reader :skip_msg def initialize(formula) @@ -19,8 +21,10 @@ def initialize(formula) @url = nil end - # Sets the regex instance variable to the argument given, returns the - # regex instance variable when no argument is given. + # Sets the `@regex` instance variable to the provided `Regexp` or returns the + # `@regex` instance variable when no argument is provided. + # @param pattern [Regexp] regex to use for matching versions in content + # @return [Regexp, nil] def regex(pattern = nil) case pattern when nil @@ -32,10 +36,12 @@ def regex(pattern = nil) end end - # Sets the skip instance variable to true, indicating that livecheck - # must be skipped for the formula. If an argument is given and present, - # its value is assigned to the skip_msg instance variable, else nil is - # assigned. + # Sets the `@skip` instance variable to `true` and sets the `@skip_msg` + # instance variable if a `String` is provided. `@skip` is used to indicate + # that the formula should be skipped and the `skip_msg` very briefly describes + # why the formula is skipped (e.g., `No longer developed or maintained`). + # @param skip_msg [String] string describing why the formula is skipped + # @return [Boolean] def skip(skip_msg = nil) if skip_msg.is_a?(String) @skip_msg = skip_msg @@ -46,16 +52,17 @@ def skip(skip_msg = nil) @skip = true end - # Should livecheck be skipped for the formula? + # Should `livecheck` skip this formula? def skip? @skip end - # Sets the strategy instance variable to the provided symbol or returns the - # strategy instance variable when no argument is provided. The strategy + # Sets the `@strategy` instance variable to the provided `Symbol` or returns + # the `@strategy` instance variable when no argument is provided. The strategy # symbols use snake case (e.g., `:page_match`) and correspond to the strategy # file name. # @param symbol [Symbol] symbol for the desired strategy + # @return [Symbol, nil] def strategy(symbol = nil) case symbol when nil @@ -67,8 +74,12 @@ def strategy(symbol = nil) end end - # Sets the url instance variable to the argument given, returns the url - # instance variable when no argument is given. + # Sets the `@url` instance variable to the provided argument or returns the + # `@url` instance variable when no argument is provided. The argument can be + # a `String` (a URL) or a supported `Symbol` corresponding to a URL in the + # formula (e.g., `:stable`, `:homepage`, or `:head`). + # @param val [String, Symbol] URL to check for version information + # @return [String, nil] def url(val = nil) @url = case val when nil @@ -84,7 +95,8 @@ def url(val = nil) end end - # Returns a Hash of all instance variable values. + # Returns a `Hash` of all instance variable values. + # @return [Hash] def to_hash { "regex" => @regex,
false
Other
Homebrew
brew
47d07b2f1baaa2a999c64b768d66ba2f7a80b892.json
Improve existing tests for Livecheck DSL
Library/Homebrew/test/livecheck_spec.rb
@@ -4,19 +4,25 @@ require "livecheck" describe Livecheck do + HOMEPAGE_URL = "https://example.com/" + STABLE_URL = "https://example.com/example-1.2.3.tar.gz" + HEAD_URL = "https://example.com/example.git" + let(:f) do formula do - url "https://brew.sh/test-0.1.tbz" + homepage HOMEPAGE_URL + url STABLE_URL + head HEAD_URL end end let(:livecheckable) { described_class.new(f) } describe "#regex" do - it "returns nil if unset" do + it "returns nil if not set" do expect(livecheckable.regex).to be nil end - it "returns the Regex if set" do + it "returns the Regexp if set" do livecheckable.regex(/foo/) expect(livecheckable.regex).to eq(/foo/) end @@ -29,14 +35,14 @@ end describe "#skip" do - it "sets the instance variable skip to true and skip_msg to nil when the argument is not present" do - livecheckable.skip + it "sets @skip to true when no argument is provided" do + expect(livecheckable.skip).to be true expect(livecheckable.instance_variable_get(:@skip)).to be true expect(livecheckable.instance_variable_get(:@skip_msg)).to be nil end - it "sets the instance variable skip to true and skip_msg to the argument when present" do - livecheckable.skip("foo") + it "sets @skip to true and @skip_msg to the provided String" do + expect(livecheckable.skip("foo")).to be true expect(livecheckable.instance_variable_get(:@skip)).to be true expect(livecheckable.instance_variable_get(:@skip_msg)).to eq("foo") end @@ -49,8 +55,9 @@ end describe "#skip?" do - it "returns the value of the instance variable skip" do + it "returns the value of @skip" do expect(livecheckable.skip?).to be false + livecheckable.skip expect(livecheckable.skip?).to be true end @@ -74,14 +81,24 @@ end describe "#url" do - it "returns nil if unset" do + it "returns nil if not set" do expect(livecheckable.url).to be nil end it "returns the URL if set" do livecheckable.url("foo") expect(livecheckable.url).to eq("foo") + livecheckable.url(:homepage) + expect(livecheckable.url).to eq(HOMEPAGE_URL) + + livecheckable.url(:stable) + expect(livecheckable.url).to eq(STABLE_URL) + + livecheckable.url(:head) + expect(livecheckable.url).to eq(HEAD_URL) + end + it "raises a TypeError if the argument isn't a String or Symbol" do expect { livecheckable.url(/foo/)
false
Other
Homebrew
brew
b99e8626e28ef3f3941d7bf9b755fbddcdbcd8b9.json
Raise TypeError in Livecheck DSL for invalid arg We previously added `raise TypeError` logic to the `Livecheck` DSL's `#strategy` method. This updates the existing methods to follow suit and modifies the tests accordingly.
Library/Homebrew/livecheck.rb
@@ -22,18 +22,28 @@ def initialize(formula) # Sets the regex instance variable to the argument given, returns the # regex instance variable when no argument is given. def regex(pattern = nil) - return @regex if pattern.nil? - - @regex = pattern + case pattern + when nil + @regex + when Regexp + @regex = pattern + else + raise TypeError, "Livecheck#regex expects a Regexp" + end end # Sets the skip instance variable to true, indicating that livecheck # must be skipped for the formula. If an argument is given and present, # its value is assigned to the skip_msg instance variable, else nil is # assigned. def skip(skip_msg = nil) + if skip_msg.is_a?(String) + @skip_msg = skip_msg + elsif skip_msg.present? + raise TypeError, "Livecheck#skip expects a String" + end + @skip = true - @skip_msg = skip_msg.presence end # Should livecheck be skipped for the formula? @@ -60,15 +70,17 @@ def strategy(symbol = nil) # Sets the url instance variable to the argument given, returns the url # instance variable when no argument is given. def url(val = nil) - return @url if val.nil? - @url = case val + when nil + return @url when :head, :stable, :devel @formula.send(val).url when :homepage @formula.homepage - else + when String val + else + raise TypeError, "Livecheck#url expects a String or valid Symbol" end end
true
Other
Homebrew
brew
b99e8626e28ef3f3941d7bf9b755fbddcdbcd8b9.json
Raise TypeError in Livecheck DSL for invalid arg We previously added `raise TypeError` logic to the `Livecheck` DSL's `#strategy` method. This updates the existing methods to follow suit and modifies the tests accordingly.
Library/Homebrew/test/livecheck_spec.rb
@@ -20,6 +20,12 @@ livecheckable.regex(/foo/) expect(livecheckable.regex).to eq(/foo/) end + + it "raises a TypeError if the argument isn't a Regexp" do + expect { + livecheckable.regex("foo") + }.to raise_error(TypeError, "Livecheck#regex expects a Regexp") + end end describe "#skip" do @@ -34,6 +40,12 @@ expect(livecheckable.instance_variable_get(:@skip)).to be true expect(livecheckable.instance_variable_get(:@skip_msg)).to eq("foo") end + + it "raises a TypeError if the argument isn't a String" do + expect { + livecheckable.skip(/foo/) + }.to raise_error(TypeError, "Livecheck#skip expects a String") + end end describe "#skip?" do @@ -69,6 +81,11 @@ it "returns the URL if set" do livecheckable.url("foo") expect(livecheckable.url).to eq("foo") + + it "raises a TypeError if the argument isn't a String or Symbol" do + expect { + livecheckable.url(/foo/) + }.to raise_error(TypeError, "Livecheck#url expects a String or valid Symbol") end end
true
Other
Homebrew
brew
70b5af4162eb27ca72f48a6ef7396fe351907b8d.json
cask/dsl/base: fix undefined method `method_missing_message'
Library/Homebrew/cask/dsl/base.rb
@@ -1,5 +1,7 @@ # frozen_string_literal: true +require "cask/utils" + module Cask class DSL class Base
false
Other
Homebrew
brew
6ecef73131178459ab9aa787bd9eaaacb48a6300.json
test: add spdx spec
Library/Homebrew/test/utils/spdx_spec.rb
@@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require "utils/spdx" + +describe SPDX do + describe ".spdx_data" do + it "has the license list version" do + expect(described_class.spdx_data["licenseListVersion"]).not_to eq(nil) + end + + it "has the release date" do + expect(described_class.spdx_data["releaseDate"]).not_to eq(nil) + end + + it "has licenses" do + expect(described_class.spdx_data["licenses"].length).not_to eq(0) + end + end + + describe ".download_latest_license_data!", :needs_network do + let(:tmp_json_path) { Pathname.new("#{TEST_TMPDIR}/spdx.json") } + + after do + FileUtils.rm tmp_json_path + end + + it "downloads latest license data" do + described_class.download_latest_license_data! to: tmp_json_path + expect(tmp_json_path).to exist + end + end +end
true
Other
Homebrew
brew
6ecef73131178459ab9aa787bd9eaaacb48a6300.json
test: add spdx spec
Library/Homebrew/utils/spdx.rb
@@ -12,9 +12,9 @@ def spdx_data @spdx_data ||= JSON.parse(JSON_PATH.read) end - def download_latest_license_data! + def download_latest_license_data!(to: JSON_PATH) latest_tag = GitHub.open_api(API_URL)["tag_name"] data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" - curl_download(data_url, to: JSON_PATH, partial: false) + curl_download(data_url, to: to, partial: false) end end
true
Other
Homebrew
brew
753b8621dfe3630e9e78ed286b59980c8efc9641.json
utils: add SPDX module
Library/Homebrew/dev-cmd/audit.rb
@@ -4,6 +4,7 @@ require "formula_versions" require "utils/curl" require "utils/notability" +require "utils/spdx" require "extend/ENV" require "formula_cellar_checks" require "cmd/search" @@ -118,8 +119,7 @@ def audit # Check style in a single batch run up front for performance style_results = Style.check_style_json(style_files, options) if style_files # load licenses - spdx = HOMEBREW_LIBRARY_PATH/"data/spdx.json" - spdx_data = JSON.parse(spdx.read) + spdx_data = SPDX.spdx_data new_formula_problem_lines = [] audit_formulae.sort.each do |f| only = only_cops ? ["style"] : args.only
true
Other
Homebrew
brew
753b8621dfe3630e9e78ed286b59980c8efc9641.json
utils: add SPDX module
Library/Homebrew/dev-cmd/update-license-data.rb
@@ -1,14 +1,11 @@ # frozen_string_literal: true require "cli/parser" -require "utils/github" +require "utils/spdx" module Homebrew module_function - SPDX_PATH = (HOMEBREW_LIBRARY_PATH/"data/spdx.json").freeze - SPDX_API_URL = "https://api.github.com/repos/spdx/license-list-data/releases/latest" - def update_license_data_args Homebrew::CLI::Parser.new do usage_banner <<~EOS @@ -29,16 +26,14 @@ def update_license_data args = update_license_data_args.parse ohai "Updating SPDX license data..." - latest_tag = GitHub.open_api(SPDX_API_URL)["tag_name"] - data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" - curl_download(data_url, to: SPDX_PATH, partial: false) + SPDX.download_latest_license_data! - Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX_PATH) if args.fail_if_not_changed? + Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::JSON_PATH) if args.fail_if_not_changed? return unless args.commit? ohai "git add" - safe_system "git", "add", SPDX_PATH + safe_system "git", "add", SPDX::JSON_PATH ohai "git commit" system "git", "commit", "--message", "data/spdx.json: update to #{latest_tag}" end
true
Other
Homebrew
brew
753b8621dfe3630e9e78ed286b59980c8efc9641.json
utils: add SPDX module
Library/Homebrew/utils/spdx.rb
@@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "utils/github" + +module SPDX + module_function + + JSON_PATH = (HOMEBREW_LIBRARY_PATH/"data/spdx.json").freeze + API_URL = "https://api.github.com/repos/spdx/license-list-data/releases/latest" + + def spdx_data + @spdx_data ||= JSON.parse(JSON_PATH.read) + end + + def download_latest_license_data! + latest_tag = GitHub.open_api(API_URL)["tag_name"] + data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" + curl_download(data_url, to: JSON_PATH, partial: false) + end +end
true
Other
Homebrew
brew
3a2dc79153db5658a0bc14188a2ea77844a4e873.json
cask/create: update template to match new style
Library/Homebrew/cask/cmd/create.rb
@@ -24,15 +24,15 @@ def run def self.template(cask_token) <<~RUBY - cask '#{cask_token}' do - version '' - sha256 '' + cask "#{cask_token}" do + version "" + sha256 "" url "https://" - name '' - homepage '' + name "" + homepage "" - app '' + app "" end RUBY end
true
Other
Homebrew
brew
3a2dc79153db5658a0bc14188a2ea77844a4e873.json
cask/create: update template to match new style
Library/Homebrew/test/cask/cmd/create_spec.rb
@@ -29,15 +29,15 @@ described_class.run("new-cask") template = File.read(Cask::CaskLoader.path("new-cask")) expect(template).to eq <<~RUBY - cask 'new-cask' do - version '' - sha256 '' + cask "new-cask" do + version "" + sha256 "" url "https://" - name '' - homepage '' + name "" + homepage "" - app '' + app "" end RUBY end
true
Other
Homebrew
brew
652480207979026e9db9ab5e19e69cbe636d6964.json
Pass remaining args to `Help`.
Library/Homebrew/brew.rb
@@ -104,8 +104,8 @@ class MissingEnvironmentVariables < RuntimeError; end # - if cmd is Cask, let Cask handle the help command instead if (empty_argv || help_flag) && cmd != "cask" require "help" - Homebrew::Help.help cmd, empty_argv: empty_argv - # `Homebrew.help` never returns, except for unknown commands. + Homebrew::Help.help cmd, remaining_args: args.remaining, empty_argv: empty_argv + # `Homebrew::Help.help` never returns, except for unknown commands. end if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd) @@ -140,7 +140,7 @@ class MissingEnvironmentVariables < RuntimeError; end end rescue UsageError => e require "help" - Homebrew::Help.help cmd, usage_error: e.message + Homebrew::Help.help cmd, remaining_args: args.remaining, usage_error: e.message rescue SystemExit => e onoe "Kernel.exit" if args.debug? && !e.success? $stderr.puts e.backtrace if args.debug?
true
Other
Homebrew
brew
652480207979026e9db9ab5e19e69cbe636d6964.json
Pass remaining args to `Help`.
Library/Homebrew/cmd/help.rb
@@ -3,7 +3,7 @@ require "help" module Homebrew - def help(cmd = nil, flags = {}) - Help.help(cmd, flags) + def help + Help.help end end
true
Other
Homebrew
brew
652480207979026e9db9ab5e19e69cbe636d6964.json
Pass remaining args to `Help`.
Library/Homebrew/help.rb
@@ -40,7 +40,7 @@ module Homebrew module Help module_function - def help(cmd = nil, empty_argv: false, usage_error: nil) + def help(cmd = nil, empty_argv: false, usage_error: nil, remaining_args: []) if cmd.nil? # Handle `brew` (no arguments). if empty_argv @@ -58,7 +58,7 @@ def help(cmd = nil, empty_argv: false, usage_error: nil) # Display command-specific (or generic) help in response to `UsageError`. if usage_error - $stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP + $stderr.puts path ? command_help(cmd, path, remaining_args: remaining_args) : HOMEBREW_HELP $stderr.puts onoe usage_error exit 1 @@ -68,16 +68,16 @@ def help(cmd = nil, empty_argv: false, usage_error: nil) return if path.nil? # Display help for internal command (or generic help if undocumented). - puts command_help(cmd, path) + puts command_help(cmd, path, remaining_args: remaining_args) exit 0 end - def command_help(cmd, path) + def command_help(cmd, path, remaining_args:) # Only some types of commands can have a parser. output = if Commands.valid_internal_cmd?(cmd) || Commands.valid_internal_dev_cmd?(cmd) || Commands.external_ruby_v2_cmd_path(cmd) - parser_help(path) + parser_help(path, remaining_args: remaining_args) end output ||= comment_help(path) @@ -90,13 +90,13 @@ def command_help(cmd, path) output end - def parser_help(path) + def parser_help(path, remaining_args:) # Let OptionParser generate help text for commands which have a parser. cmd_parser = CLI::Parser.from_cmd_path(path) return unless cmd_parser # Try parsing arguments here in order to show formula options in help output. - cmd_parser.parse(Homebrew.args.remaining, ignore_invalid_options: true) + cmd_parser.parse(remaining_args, ignore_invalid_options: true) cmd_parser.generate_help_text end
true
Other
Homebrew
brew
62671b1703c8fb8fd17d5548ff2f21df43678fd7.json
Remove wrong test.
Library/Homebrew/test/rubocops/lines_spec.rb
@@ -821,18 +821,6 @@ class Foo < Formula RUBY end - it "Using ARGV to check options" do - expect_no_offenses(<<~RUBY) - class Foo < Formula - desc "foo" - url 'https://brew.sh/foo-1.0.tgz' - def install - verbose = Homebrew.args.verbose? - end - end - RUBY - end - it 'man+"man8" usage' do expect_offense(<<~RUBY) class Foo < Formula
false
Other
Homebrew
brew
5db764f3cb3d8b3e356cc8f209ff4c52c126362e.json
Pass `debug?` and `verbose?` in `brew style`.
Library/Homebrew/dev-cmd/audit.rb
@@ -103,7 +103,7 @@ def audit only_cops = args.only_cops except_cops = args.except_cops - options = { fix: args.fix? } + options = { fix: args.fix?, debug: args.debug?, verbose: args.verbose? } if only_cops options[:only_cops] = only_cops
true
Other
Homebrew
brew
5db764f3cb3d8b3e356cc8f209ff4c52c126362e.json
Pass `debug?` and `verbose?` in `brew style`.
Library/Homebrew/dev-cmd/style.rb
@@ -50,7 +50,9 @@ def style only_cops = args.only_cops except_cops = args.except_cops - options = { fix: args.fix?, display_cop_names: args.display_cop_names? } + options = { + fix: args.fix?, display_cop_names: args.display_cop_names?, debug: args.debug?, verbose: args.verbose? + } if only_cops options[:only_cops] = only_cops elsif except_cops
true
Other
Homebrew
brew
5db764f3cb3d8b3e356cc8f209ff4c52c126362e.json
Pass `debug?` and `verbose?` in `brew style`.
Library/Homebrew/style.rb
@@ -16,7 +16,9 @@ def check_style_json(files, **options) check_style_impl(files, :json, **options) end - def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops: nil, display_cop_names: false) + def check_style_impl(files, output_type, + fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, + debug: false, verbose: false) Homebrew.install_bundler_gems! require "rubocop" require "rubocops" @@ -30,7 +32,8 @@ def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops "--parallel" end - args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose? + args += ["--extra-details"] if verbose + args += ["--display-cop-names"] if display_cop_names || verbose if except_cops except_cops.map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") } @@ -77,15 +80,13 @@ def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops case output_type when :print - args << "--debug" if Homebrew.args.debug? - args << "--display-cop-names" if display_cop_names + args << "--debug" if debug args << "--format" << "simple" if files.present? system(cache_env, "rubocop", *args) rubocop_success = $CHILD_STATUS.success? when :json json, err, status = - Open3.capture3(cache_env, "rubocop", - "--format", "json", *args) + Open3.capture3(cache_env, "rubocop", "--format", "json", *args) # exit status of 1 just means violations were found; other numbers mean # execution errors. # exitstatus can also be nil if RuboCop process crashes, e.g. due to
true
Other
Homebrew
brew
add10377b893d8e970bc4122a32f0dfcd1091481.json
Pass `debug?` and `verbose?` to `Cleaner`.
Library/Homebrew/cleaner.rb
@@ -10,9 +10,15 @@ # * sets permissions on executables # * removes unresolved symlinks class Cleaner + extend Predicable + + attr_predicate :verbose?, :debug? + # Create a cleaner for the given formula - def initialize(f) + def initialize(f, verbose: false, debug: false) @f = f + @verbose = verbose + @debug = debug end # Clean the keg of formula @f @@ -58,7 +64,7 @@ def prune # actual files gets removed correctly. dirs.reverse_each do |d| if d.children.empty? - puts "rmdir: #{d} (empty)" if Homebrew.args.verbose? + puts "rmdir: #{d} (empty)" if verbose? d.rmdir end end @@ -109,7 +115,7 @@ def clean_dir(d) else 0444 end - if Homebrew.args.debug? + if debug? old_perms = path.stat.mode & 0777 odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms end
true
Other
Homebrew
brew
add10377b893d8e970bc4122a32f0dfcd1091481.json
Pass `debug?` and `verbose?` to `Cleaner`.
Library/Homebrew/formula_installer.rb
@@ -956,7 +956,7 @@ def fix_dynamic_linkage(keg) def clean ohai "Cleaning" if verbose? - Cleaner.new(formula).clean + Cleaner.new(formula, verbose: verbose?, debug: debug?).clean rescue Exception => e # rubocop:disable Lint/RescueException opoo "The cleaning step did not complete successfully" puts "Still, the installation was successful, so we will link it into your prefix"
true
Other
Homebrew
brew
57fa48b7581ebf3c7acae959bc7ec88e83f50118.json
Remove unneeded call to `#shutup!` in spec.
Library/Homebrew/test/download_strategies_spec.rb
@@ -121,7 +121,6 @@ def setup_git_repo git_commit_all end - subject.shutup! expect(subject.fetch_last_commit).to eq("f68266e") end end
false
Other
Homebrew
brew
99bff13cbbfffe17706e1b60c633e6200ad527f1.json
cmd/tap-info: improve comma usage. Broken in https://github.com/Homebrew/brew/pull/8230.
Library/Homebrew/cmd/tap-info.rb
@@ -69,14 +69,14 @@ def print_tap_info(taps) puts unless i.zero? info = "#{tap}: " if tap.installed? - info += ", private" if tap.private? - info += if (contents = tap.contents).empty? - ", no commands/casks/formulae" + info += if (contents = tap.contents).blank? + "no commands/casks/formulae" else - ", #{contents.join(", ")}" + contents.join(", ") end + info += ", private" if tap.private? info += "\n#{tap.path} (#{tap.path.abv})" - info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}" + info += "\nFrom: #{tap.remote.blank? ? "N/A" : tap.remote}" else info += "Not installed" end
false
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
Library/Homebrew/cmd/--cache.rb
@@ -13,7 +13,7 @@ module Homebrew def __cache_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `--cache` [<options>] [<formula>] + `--cache` [<options>] [<formula|cask>] Display Homebrew's download cache. See also `HOMEBREW_CACHE`. @@ -23,12 +23,12 @@ def __cache_args description: "Show the cache file used when building from source." switch "--force-bottle", description: "Show the cache file used when pouring a bottle." - switch "--formula", + switch "--formulae", description: "Only show cache files for formulae." - switch "--cask", + switch "--casks", description: "Only show cache files for casks." conflicts "--build-from-source", "--force-bottle" - conflicts "--formula", "--cask" + conflicts "--formulae", "--casks" end end @@ -37,11 +37,11 @@ def __cache if args.no_named? puts HOMEBREW_CACHE - elsif args.formula? + elsif args.formulae? args.named.each do |name| print_formula_cache name, args: args end - elsif args.cask? + elsif args.casks? args.named.each do |name| print_cask_cache name end
true
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
Library/Homebrew/cmd/list.rb
@@ -11,9 +11,9 @@ module Homebrew def list_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `list`, `ls` [<options>] [<formula>] + `list`, `ls` [<options>] [<formula|cask>] - List all installed formulae. + List all installed formulae or casks If <formula> is provided, summarise the paths within its current keg. EOS @@ -32,8 +32,10 @@ def list_args switch "--pinned", description: "Show the versions of pinned formulae, or only the specified (pinned) "\ "formulae if <formula> are provided. See also `pin`, `unpin`." - switch "--cask", - description: "List casks" + switch "--formulae", + description: "List only formulae." + switch "--casks", + description: "List only casks." # passed through to ls switch "-1", description: "Force output to be one entry per line. " \ @@ -46,14 +48,16 @@ def list_args switch "-t", description: "Sort by time modified, listing most recently modified first." - ["--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each { |flag| conflicts "--cask", flag } + ["--formulae", "--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each do |flag| + conflicts "--casks", flag + end end end def list args = list_args.parse - return list_casks(args: args) if args.cask? + return list_casks(args: args) if args.casks? return list_unbrewed if args.unbrewed?
true
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
Library/Homebrew/cmd/outdated.rb
@@ -12,15 +12,19 @@ module Homebrew def outdated_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `outdated` [<options>] [<formula>] + `outdated` [<options>] [<formula>|<cask>] - List installed formulae that have an updated version available. By default, version + List installed casks and formulae that have an updated version available. By default, version information is displayed in interactive shells, and suppressed otherwise. EOS switch "-q", "--quiet", description: "List only the names of outdated kegs (takes precedence over `--verbose`)." switch "-v", "--verbose", description: "Include detailed version information." + switch "--formulae", + description: "Only output outdated formulae." + switch "--casks", + description: "Only output outdated casks." flag "--json", description: "Print output in JSON format. There are two versions: v1 and v2. " \ "v1 is deprecated and is currently the default if no version is specified. " \ @@ -31,13 +35,9 @@ def outdated_args "updates when a new stable or development version has been released." switch "--greedy", description: "Print outdated casks with `auto_updates` or `version :latest`." - switch "--formula", - description: "Treat all arguments as formulae." - switch "--cask", - description: "Treat all arguments as casks." conflicts "--quiet", "--verbose", "--json" - conflicts "--formula", "--cask" + conflicts "--formulae", "--casks" end end @@ -49,7 +49,7 @@ def outdated # TODO: enable for next major/minor release # odeprecated "brew outdated --json#{json_version == :v1 ? "=v1" : ""}", "brew outdated --json=v2" - outdated = if args.formula? || !args.cask? + outdated = if args.formulae? || !args.casks? outdated_formulae args: args else outdated_casks args: args @@ -58,9 +58,9 @@ def outdated puts JSON.generate(json_info(outdated, args: args)) when :v2 - formulae, casks = if args.formula? + formulae, casks = if args.formulae? [outdated_formulae(args: args), []] - elsif args.cask? + elsif args.casks? [[], outdated_casks(args: args)] else outdated_formulae_casks args: args @@ -75,9 +75,9 @@ def outdated outdated = formulae + casks else - outdated = if args.formula? + outdated = if args.formulae? outdated_formulae args: args - elsif args.cask? + elsif args.casks? outdated_casks args: args else outdated_formulae_casks(args: args).flatten
true
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
Library/Homebrew/cmd/upgrade.rb
@@ -14,18 +14,22 @@ module Homebrew def upgrade_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `upgrade` [<options>] [<formula>] + `upgrade` [<options>] [<formula>|<cask>] - Upgrade outdated, unpinned formulae using the same options they were originally - installed with, plus any appended brew formula options. If <formula> are specified, - upgrade only the given <formula> kegs (unless they are pinned; see `pin`, `unpin`). + Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally + installed with, plus any appended brew formula options. If <cask> or <formula> are specified, + upgrade only the given <cask> or <formula> kegs (unless they are pinned; see `pin`, `unpin`). Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the upgraded formulae or, every 30 days, for all formulae. EOS switch "-d", "--debug", description: "If brewing fails, open an interactive debugging session with access to IRB "\ "or a shell inside the temporary build directory." + switch "--formulae", + description: "Only upgrade outdated formulae." + switch "--casks", + description: "Only upgrade outdated casks." switch "-s", "--build-from-source", description: "Compile <formula> from source even if a bottle is available." switch "-i", "--interactive", @@ -56,6 +60,12 @@ def upgrade_args switch "--greedy", description: "Upgrade casks with `auto_updates` or `version :latest`" conflicts "--build-from-source", "--force-bottle" + conflicts "--formulae", "--greedy" + ["--formulae", "-s", "--build-from-source", "-i", "--interactive", + "--force-bottle", "--fetch-HEAD", "--ignore-pinned", "--keep-tmp", + "--display-times"].each do |flag| + conflicts "--casks", flag + end formula_options end end @@ -67,11 +77,11 @@ def upgrade # If one or more formulae are specified, but no casks were # specified, we want to make note of that so we don't # try to upgrade all outdated casks. - named_formulae_specified = !formulae.empty? && casks.empty? - named_casks_specified = !casks.empty? && formulae.empty? + upgrade_formulae = formulae.present? && casks.blank? && !args.casks? + upgrade_casks = casks.present? && formulae.blank? && !args.formulae? - upgrade_outdated_formulae(formulae, args: args) unless named_casks_specified - upgrade_outdated_casks(casks, args: args) unless named_formulae_specified + upgrade_outdated_formulae(formulae, args: args) unless upgrade_casks + upgrade_outdated_casks(casks, args: args) unless upgrade_formulae end def upgrade_outdated_formulae(formulae, args:)
true
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
docs/Manpage.md
@@ -274,9 +274,9 @@ automatically when you install formulae but can be useful for DIY installations. * `-f`, `--force`: Allow keg-only formulae to be linked. -### `list`, `ls` [*`options`*] [*`formula`*] +### `list`, `ls` [*`options`*] [*`formula|cask`*] -List all installed formulae. +List all installed formulae or casks If *`formula`* is provided, summarise the paths within its current keg. @@ -290,8 +290,10 @@ If *`formula`* is provided, summarise the paths within its current keg. Only show formulae with multiple versions installed. * `--pinned`: Show the versions of pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`. -* `--cask`: - List casks +* `--formulae`: + List only formulae. +* `--casks`: + List only casks. * `-1`: Force output to be one entry per line. This is the default when output is not to a terminal. * `-l`: @@ -347,26 +349,26 @@ Show install options specific to *`formula`*. * `--command`: Show options for the specified *`command`*. -### `outdated` [*`options`*] [*`formula`*] +### `outdated` [*`options`*] [*`formula`*|*`cask`*] -List installed formulae that have an updated version available. By default, -version information is displayed in interactive shells, and suppressed +List installed casks and formulae that have an updated version available. By +default, version information is displayed in interactive shells, and suppressed otherwise. * `-q`, `--quiet`: List only the names of outdated kegs (takes precedence over `--verbose`). * `-v`, `--verbose`: Include detailed version information. +* `--formulae`: + Only output outdated formulae. +* `--casks`: + Only output outdated casks. * `--json`: Print output in JSON format. There are two versions: v1 and v2. v1 is deprecated and is currently the default if no version is specified. v2 prints outdated formulae and casks. * `--fetch-HEAD`: Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository's HEAD will only be checked for updates when a new stable or development version has been released. * `--greedy`: Print outdated casks with `auto_updates` or `version :latest`. -* `--formula`: - Treat all arguments as formulae. -* `--cask`: - Treat all arguments as casks. ### `pin` *`formula`* @@ -536,18 +538,22 @@ Fetch and reset Homebrew and all tap repositories (or any specified *`repository *Note:* this will destroy all your uncommitted or committed changes. -### `upgrade` [*`options`*] [*`formula`*] +### `upgrade` [*`options`*] [*`formula`*|*`cask`*] -Upgrade outdated, unpinned formulae using the same options they were originally -installed with, plus any appended brew formula options. If *`formula`* are -specified, upgrade only the given *`formula`* kegs (unless they are pinned; see -`pin`, `unpin`). +Upgrade outdated casks and outdated, unpinned formulae using the same options +they were originally installed with, plus any appended brew formula options. If +*`cask`* or *`formula`* are specified, upgrade only the given *`cask`* or *`formula`* +kegs (unless they are pinned; see `pin`, `unpin`). Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the upgraded formulae or, every 30 days, for all formulae. * `-d`, `--debug`: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory. +* `--formulae`: + Only upgrade outdated formulae. +* `--casks`: + Only upgrade outdated casks. * `-s`, `--build-from-source`: Compile *`formula`* from source even if a bottle is available. * `-i`, `--interactive`: @@ -595,7 +601,7 @@ formulae that use *`formula`*. By default, `uses` shows all formulae that specif * `--HEAD`: Show usage of *`formula`* by HEAD builds. -### `--cache` [*`options`*] [*`formula`*] +### `--cache` [*`options`*] [*`formula|cask`*] Display Homebrew's download cache. See also `HOMEBREW_CACHE`. @@ -605,9 +611,9 @@ If *`formula`* is provided, display the file or directory used to cache *`formul Show the cache file used when building from source. * `--force-bottle`: Show the cache file used when pouring a bottle. -* `--formula`: +* `--formulae`: Only show cache files for formulae. -* `--cask`: +* `--casks`: Only show cache files for casks. ### `--caskroom` [*`cask`*] @@ -1211,7 +1217,7 @@ flags which will help find keg-only dependencies like `openssl`, `icu4c`, etc. `install` won't output a `Brewfile.lock.json`. * `--all`: `list` all dependencies. -* `--brews`: +* `--formulae`: `list` Homebrew dependencies. * `--casks`: `list` Homebrew Cask dependencies.
true
Other
Homebrew
brew
ced084bd49fa58a239d283997fcf6b5e84054b11.json
Handle casks in commands more consistently. - Ensure the usage documentation always mentions casks when appropriate - Use --formulae or --casks consistently - Provide --formulae and --casks switches to upgrade - Mark more switches as conflicting
manpages/brew.1
@@ -366,8 +366,8 @@ List files which would be linked or deleted by \fBbrew link \-\-overwrite\fR wit \fB\-f\fR, \fB\-\-force\fR Allow keg\-only formulae to be linked\. . -.SS "\fBlist\fR, \fBls\fR [\fIoptions\fR] [\fIformula\fR]" -List all installed formulae\. +.SS "\fBlist\fR, \fBls\fR [\fIoptions\fR] [\fIformula|cask\fR]" +List all installed formulae or casks . .P If \fIformula\fR is provided, summarise the paths within its current keg\. @@ -393,8 +393,12 @@ Only show formulae with multiple versions installed\. Show the versions of pinned formulae, or only the specified (pinned) formulae if \fIformula\fR are provided\. See also \fBpin\fR, \fBunpin\fR\. . .TP -\fB\-\-cask\fR -List casks +\fB\-\-formulae\fR +List only formulae\. +. +.TP +\fB\-\-casks\fR +List only casks\. . .TP \fB\-1\fR @@ -468,8 +472,8 @@ Show options for all available formulae\. \fB\-\-command\fR Show options for the specified \fIcommand\fR\. . -.SS "\fBoutdated\fR [\fIoptions\fR] [\fIformula\fR]" -List installed formulae that have an updated version available\. By default, version information is displayed in interactive shells, and suppressed otherwise\. +.SS "\fBoutdated\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]" +List installed casks and formulae that have an updated version available\. By default, version information is displayed in interactive shells, and suppressed otherwise\. . .TP \fB\-q\fR, \fB\-\-quiet\fR @@ -480,6 +484,14 @@ List only the names of outdated kegs (takes precedence over \fB\-\-verbose\fR)\. Include detailed version information\. . .TP +\fB\-\-formulae\fR +Only output outdated formulae\. +. +.TP +\fB\-\-casks\fR +Only output outdated casks\. +. +.TP \fB\-\-json\fR Print output in JSON format\. There are two versions: v1 and v2\. v1 is deprecated and is currently the default if no version is specified\. v2 prints outdated formulae and casks\. . @@ -491,14 +503,6 @@ Fetch the upstream repository to detect if the HEAD installation of the formula \fB\-\-greedy\fR Print outdated casks with \fBauto_updates\fR or \fBversion :latest\fR\. . -.TP -\fB\-\-formula\fR -Treat all arguments as formulae\. -. -.TP -\fB\-\-cask\fR -Treat all arguments as casks\. -. .SS "\fBpin\fR \fIformula\fR" Pin the specified \fIformula\fR, preventing them from being upgraded when issuing the \fBbrew upgrade\fR \fIformula\fR command\. See also \fBunpin\fR\. . @@ -696,8 +700,8 @@ Fetch and reset Homebrew and all tap repositories (or any specified \fIrepositor .P \fINote:\fR this will destroy all your uncommitted or committed changes\. . -.SS "\fBupgrade\fR [\fIoptions\fR] [\fIformula\fR]" -Upgrade outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options\. If \fIformula\fR are specified, upgrade only the given \fIformula\fR kegs (unless they are pinned; see \fBpin\fR, \fBunpin\fR)\. +.SS "\fBupgrade\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]" +Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options\. If \fIcask\fR or \fIformula\fR are specified, upgrade only the given \fIcask\fR or \fIformula\fR kegs (unless they are pinned; see \fBpin\fR, \fBunpin\fR)\. . .P Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be run for the upgraded formulae or, every 30 days, for all formulae\. @@ -707,6 +711,14 @@ Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory\. . .TP +\fB\-\-formulae\fR +Only upgrade outdated formulae\. +. +.TP +\fB\-\-casks\fR +Only upgrade outdated casks\. +. +.TP \fB\-s\fR, \fB\-\-build\-from\-source\fR Compile \fIformula\fR from source even if a bottle is available\. . @@ -785,7 +797,7 @@ Show usage of \fIformula\fR by development builds\. \fB\-\-HEAD\fR Show usage of \fIformula\fR by HEAD builds\. . -.SS "\fB\-\-cache\fR [\fIoptions\fR] [\fIformula\fR]" +.SS "\fB\-\-cache\fR [\fIoptions\fR] [\fIformula|cask\fR]" Display Homebrew\'s download cache\. See also \fBHOMEBREW_CACHE\fR\. . .P @@ -800,11 +812,11 @@ Show the cache file used when building from source\. Show the cache file used when pouring a bottle\. . .TP -\fB\-\-formula\fR +\fB\-\-formulae\fR Only show cache files for formulae\. . .TP -\fB\-\-cask\fR +\fB\-\-casks\fR Only show cache files for casks\. . .SS "\fB\-\-caskroom\fR [\fIcask\fR]" @@ -1569,7 +1581,7 @@ Read the \fBBrewfile\fR from \fB~/\.Brewfile\fR\. \fBlist\fR all dependencies\. . .TP -\fB\-\-brews\fR +\fB\-\-formulae\fR \fBlist\fR Homebrew dependencies\. . .TP
true
Other
Homebrew
brew
72985277e84339912cc4f6771cfba12fd7e0b508.json
Add strategy to livecheck DSL
Library/Homebrew/livecheck.rb
@@ -15,6 +15,7 @@ def initialize(formula) @regex = nil @skip = false @skip_msg = nil + @strategy = nil @url = nil end @@ -40,6 +41,22 @@ def skip? @skip end + # Sets the strategy instance variable to the provided symbol or returns the + # strategy instance variable when no argument is provided. The strategy + # symbols use snake case (e.g., `:page_match`) and correspond to the strategy + # file name. + # @param symbol [Symbol] symbol for the desired strategy + def strategy(symbol = nil) + case symbol + when nil + @strategy + when Symbol + @strategy = symbol + else + raise TypeError, "Livecheck#strategy expects a Symbol" + end + end + # Sets the url instance variable to the argument given, returns the url # instance variable when no argument is given. def url(val = nil) @@ -61,6 +78,7 @@ def to_hash "regex" => @regex, "skip" => @skip, "skip_msg" => @skip_msg, + "strategy" => @strategy, "url" => @url, } end
true
Other
Homebrew
brew
72985277e84339912cc4f6771cfba12fd7e0b508.json
Add strategy to livecheck DSL
Library/Homebrew/test/livecheck_spec.rb
@@ -44,6 +44,23 @@ end end + describe "#strategy" do + it "returns nil if not set" do + expect(livecheckable.strategy).to be nil + end + + it "returns the Symbol if set" do + livecheckable.strategy(:page_match) + expect(livecheckable.strategy).to eq(:page_match) + end + + it "raises a TypeError if the argument isn't a Symbol" do + expect { + livecheckable.strategy("page_match") + }.to raise_error(TypeError, "Livecheck#strategy expects a Symbol") + end + end + describe "#url" do it "returns nil if unset" do expect(livecheckable.url).to be nil @@ -57,7 +74,15 @@ describe "#to_hash" do it "returns a Hash of all instance variables" do - expect(livecheckable.to_hash).to eq({ "regex"=>nil, "skip"=>false, "skip_msg"=>nil, "url"=>nil }) + expect(livecheckable.to_hash).to eq( + { + "regex" => nil, + "skip" => false, + "skip_msg" => nil, + "strategy" => nil, + "url" => nil, + }, + ) end end end
true
Other
Homebrew
brew
a3278ad3453b42d0e15a487d1991b85f9f9b1e01.json
add bump spec
Library/Homebrew/dev-cmd/bump.rb
@@ -23,9 +23,10 @@ def bump_args end def bump - bump_args.parse + args = bump_args.parse - requested_formula = Homebrew.args.formula + requested_formula = args.formula + requested_limit = args.limit ? args.limit.to_i : nil requested_formula&.downcase! raise FormulaUnavailableError, requested_formula if requested_formula && !validate_formula(requested_formula) @@ -36,8 +37,12 @@ def bump Repology.parse_api_response end - validated_formulae = Repology.validate_and_format_packages(repology_data) - display(validated_formulae) + if repology_data.blank? + ohai "No Repology data found." + else + validated_formulae = Repology.validate_and_format_packages(repology_data, requested_limit) + display(validated_formulae) + end end def validate_formula(formula_name) @@ -57,7 +62,7 @@ def display(formulae) title = (up_to_date?(package_details) ? formula + " is up to date!" : formula).to_s ohai title puts "Current formula version: #{package_details[:current_formula_version]}" - puts "Latest Repology version: #{package_details[:repology_latest_version]}" + puts "Latest Repology version: #{package_details[:repology_latest_version] || "Not found"}" puts "Latest livecheck version: #{package_details[:livecheck_latest_version] || "Not found"}" puts "Open pull requests: #{package_details[:open_pull_requests] || "None"}" end
true
Other
Homebrew
brew
a3278ad3453b42d0e15a487d1991b85f9f9b1e01.json
add bump spec
Library/Homebrew/test/dev-cmd/bump_spec.rb
@@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "cmd/shared_examples/args_parse" + +describe "Homebrew.bump_args" do + it_behaves_like "parseable arguments" +end
true
Other
Homebrew
brew
a3278ad3453b42d0e15a487d1991b85f9f9b1e01.json
add bump spec
Library/Homebrew/utils/repology.rb
@@ -53,7 +53,7 @@ def parse_api_response outdated_packages end - def validate_and_format_packages(outdated_repology_packages) + def validate_and_format_packages(outdated_repology_packages, limit) packages = {} outdated_repology_packages.each do |_name, repositories| # identify homebrew repo @@ -68,7 +68,7 @@ def validate_and_format_packages(outdated_repology_packages) package_details = format_package(srcname, latest_version) packages[srcname] = package_details unless package_details.nil? - break if Homebrew.args.limit && packages.size >= Homebrew.args.limit.to_i + break if limit && packages.size >= limit end packages
true
Other
Homebrew
brew
b1ca2f7e3c4499d347a831d988e91ea93d01d65e.json
Add shared method for upgrading casks.
Library/Homebrew/cask/cmd/upgrade.rb
@@ -1,5 +1,6 @@ # frozen_string_literal: true +require "env_config" require "cask/config" module Cask @@ -17,35 +18,65 @@ def initialize(*) end def run - outdated_casks = casks(alternative: lambda { + self.class.upgrade_casks( + *casks, + force: force?, + greedy: greedy?, + dry_run: dry_run?, + binaries: binaries?, + quarantine: quarantine?, + require_sha: require_sha?, + skip_cask_deps: skip_cask_deps?, + verbose: verbose?, + ) + end + + def self.upgrade_casks( + *casks, + force: false, greedy: false, dry_run: false, binaries: true, skip_cask_deps: false, verbose: false, + quarantine: nil, require_sha: nil + ) + # TODO: Handle this in `CLI::Parser`. + quarantine = Homebrew::EnvConfig.cask_opts_quarantine? if quarantine.nil? + require_sha = Homebrew::EnvConfig.cask_opts_require_sha? if require_sha.nil? + + outdated_casks = if casks.empty? Caskroom.casks.select do |cask| - cask.outdated?(greedy?) + cask.outdated?(greedy) end - }).select do |cask| - raise CaskNotInstalledError, cask unless cask.installed? || force? + else + casks.select do |cask| + raise CaskNotInstalledError, cask unless cask.installed? || force - cask.outdated?(true) + cask.outdated?(true) + end end if outdated_casks.empty? oh1 "No Casks to upgrade" return end - ohai "Casks with `auto_updates` or `version :latest` will not be upgraded" if args.empty? && !greedy? - verb = dry_run? ? "Would upgrade" : "Upgrading" + ohai "Casks with `auto_updates` or `version :latest` will not be upgraded" if casks.empty? && !greedy + + verb = dry_run ? "Would upgrade" : "Upgrading" oh1 "#{verb} #{outdated_casks.count} #{"outdated package".pluralize(outdated_casks.count)}:" + caught_exceptions = [] upgradable_casks = outdated_casks.map { |c| [CaskLoader.load(c.installed_caskfile), c] } puts upgradable_casks .map { |(old_cask, new_cask)| "#{new_cask.full_name} #{old_cask.version} -> #{new_cask.version}" } .join(", ") - return if dry_run? + return if dry_run upgradable_casks.each do |(old_cask, new_cask)| - upgrade_cask(old_cask, new_cask) + upgrade_cask( + old_cask, new_cask, + binaries: binaries, force: force, skip_cask_deps: skip_cask_deps, verbose: verbose, + quarantine: quarantine, require_sha: require_sha + ) rescue => e caught_exceptions << e.exception("#{new_cask.full_name}: #{e}") next @@ -56,26 +87,29 @@ def run raise caught_exceptions.first if caught_exceptions.count == 1 end - def upgrade_cask(old_cask, new_cask) + def self.upgrade_cask( + old_cask, new_cask, + binaries:, force:, quarantine:, require_sha:, skip_cask_deps:, verbose: + ) odebug "Started upgrade process for Cask #{old_cask}" old_config = old_cask.config old_cask_installer = - Installer.new(old_cask, binaries: binaries?, - verbose: verbose?, - force: force?, + Installer.new(old_cask, binaries: binaries, + verbose: verbose, + force: force, upgrade: true) new_cask.config = Config.global.merge(old_config) new_cask_installer = - Installer.new(new_cask, binaries: binaries?, - verbose: verbose?, - force: force?, - skip_cask_deps: skip_cask_deps?, - require_sha: require_sha?, + Installer.new(new_cask, binaries: binaries, + verbose: verbose, + force: force, + skip_cask_deps: skip_cask_deps, + require_sha: require_sha, upgrade: true, - quarantine: quarantine?) + quarantine: quarantine) started_upgrade = false new_artifacts_installed = false
true
Other
Homebrew
brew
b1ca2f7e3c4499d347a831d988e91ea93d01d65e.json
Add shared method for upgrading casks.
Library/Homebrew/cmd/upgrade.rb
@@ -133,10 +133,16 @@ def upgrade_outdated_formulae(formulae, args:) end def upgrade_outdated_casks(casks, args:) - cask_upgrade = Cask::Cmd::Upgrade.new(casks) - cask_upgrade.force = args.force? - cask_upgrade.dry_run = args.dry_run? - cask_upgrade.greedy = args.greedy? - cask_upgrade.run + Cask::Cmd::Upgrade.upgrade_casks( + *casks, + force: args.force?, + greedy: args.greedy?, + dry_run: args.dry_run?, + binaries: args.binaries?, + quarantine: args.quarantine?, + require_sha: args.require_sha?, + skip_cask_deps: args.skip_cask_deps?, + verbose: args.verbose?, + ) end end
true
Other
Homebrew
brew
b1ca2f7e3c4499d347a831d988e91ea93d01d65e.json
Add shared method for upgrading casks.
Library/Homebrew/env_config.rb
@@ -54,6 +54,9 @@ module EnvConfig "Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.", default: HOMEBREW_DEFAULT_CACHE, }, + HOMEBREW_CASK_OPTS: { + description: "Options which should be used for all `cask` commands.", + }, HOMEBREW_CLEANUP_MAX_AGE_DAYS: { description: "Cleanup all cached files older than this many days.", default: 120, @@ -293,7 +296,7 @@ def env_method_name(env, hash) end elsif hash[:default].present? # Needs a custom implementation. - next if env == "HOMEBREW_MAKE_JOBS" + next if ["HOMEBREW_MAKE_JOBS", "HOMEBREW_CASK_OPTS"].include?(env) define_method(method_name) do ENV[env].presence || hash.fetch(:default).to_s @@ -315,5 +318,22 @@ def make_jobs .call .to_s end + + def cask_opts + Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", "")) + end + + def cask_opts_quarantine? + cask_opts.reverse_each do |opt| + return true if opt == "--quarantine" + return false if opt == "--no-quarantine" + end + + true + end + + def cask_opts_require_sha? + cask_opts.include?("--require-sha") + end end end
true
Other
Homebrew
brew
5157c08327f58ffdd9fe6aaf6acfa2bd08b1ba41.json
style: clarify GitHub .git error message
Library/Homebrew/rubocops/homepage.rb
@@ -64,7 +64,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) when %r{^https://github.com.*\.git} offending_node(parameters(homepage_node).first) - problem "GitHub URLs (`#{homepage}`) should not end with .git" + problem "GitHub homepages (`#{homepage}`) should not end with .git" # There's an auto-redirect here, but this mistake is incredibly common too. # Only applies to the homepage and subdomains for now, not the FTP URLs.
true
Other
Homebrew
brew
5157c08327f58ffdd9fe6aaf6acfa2bd08b1ba41.json
style: clarify GitHub .git error message
Library/Homebrew/test/rubocops/homepage_spec.rb
@@ -104,7 +104,7 @@ class #{name.capitalize} < Formula column: 2, source: source }] elsif homepage.match?("https://github.com/foo/bar.git") - expected_offenses = [{ message: "GitHub URLs (`#{homepage}`) should not end with .git", + expected_offenses = [{ message: "GitHub homepages (`#{homepage}`) should not end with .git", severity: :convention, line: 2, column: 11,
true
Other
Homebrew
brew
f1e06b865a0eabaf938a2f1026853642db253e5d.json
audit: permit license groups
Library/Homebrew/dev-cmd/audit.rb
@@ -335,6 +335,14 @@ def audit_formula_name 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 + def audit_license if formula.license.present? non_standard_licenses = formula.license.map do |license| @@ -355,12 +363,12 @@ def audit_license github_license = GitHub.get_repo_license(user, repo) return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) + return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| formula.license.include? license } - problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ - "but Formulae license states: #{formula.license}." + problem "Formula license #{formula.license} does not match GitHub license #{Array(github_license)}." - elsif @new_formula - problem "No license specified for package." + elsif @new_formula && @core_tap + problem "Formulae in homebrew/core must specify a license." end end
true
Other
Homebrew
brew
f1e06b865a0eabaf938a2f1026853642db253e5d.json
audit: permit license groups
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -102,14 +102,14 @@ class Foo < Formula end it "detects no license info" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true, core_tap: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" end RUBY fa.audit_license - expect(fa.problems.first).to match "No license specified for package." + expect(fa.problems.first).to match "Formulae in homebrew/core must specify a license." end it "detects if license is not a standard spdx-id" do @@ -174,6 +174,34 @@ class Cask < Formula expect(fa.problems).to be_empty end + it "checks online and verifies that a standard license id is in the same exempted license group"\ + "as what is indicated on its Github repo" do + fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, new_formula: true + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "GPL-3.0-or-later" + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "checks online and verifies that a standard license array is in the same exempted license group"\ + "as what is indicated on its Github repo" do + fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, new_formula: true + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license ["GPL-3.0-or-later", "MIT"] + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + it "checks online and detects that a formula-specified license is not "\ "the same as what is indicated on its Github repository" do fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true @@ -185,8 +213,8 @@ class Cask < Formula RUBY fa.audit_license - expect(fa.problems.first).to match "License mismatch - GitHub license is: [\"GPL-3.0\"], "\ - "but Formulae license states: #{Array(standard_mismatch_spdx_id)}." + expect(fa.problems.first).to match "Formula license #{Array(standard_mismatch_spdx_id)} "\ + "does not match GitHub license [\"GPL-3.0\"]." end it "checks online and detects that an array of license does not contain "\ @@ -200,8 +228,8 @@ class Cask < Formula RUBY fa.audit_license - expect(fa.problems.first).to match "License mismatch - GitHub license is: [\"GPL-3.0\"], "\ - "but Formulae license states: #{Array(license_array_mismatch)}." + expect(fa.problems.first).to match "Formula license #{license_array_mismatch} "\ + "does not match GitHub license [\"GPL-3.0\"]." end it "checks online and verifies that an array of license contains "\
true
Other
Homebrew
brew
86359c4c91d8b4d2934828129a8de9cd310adf01.json
Implement `Homebrew.args` compatibility layer.
Library/Homebrew/compat.rb
@@ -1,5 +1,7 @@ # frozen_string_literal: true +require "compat/dependencies_helpers" +require "compat/cli/parser" require "compat/extend/nil" require "compat/extend/string" require "compat/formula"
true
Other
Homebrew
brew
86359c4c91d8b4d2934828129a8de9cd310adf01.json
Implement `Homebrew.args` compatibility layer.
Library/Homebrew/compat/cli/parser.rb
@@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Homebrew + module CLI + class Parser + module Compat + module DeprecatedArgs + def respond_to_missing?(*) + super + end + + def method_missing(method, *) + if ![:debug?, :quiet?, :verbose?].include?(method) && !@printed_args_warning + odeprecated "Homebrew.args", "`args = <command>_args.parse` and pass `args` along the call chain" + @printed_args_warning = true + end + + super + end + end + + def parse(*) + args = super + Homebrew.args = args.dup.extend(DeprecatedArgs) + args + end + end + + prepend Compat + end + end +end
true
Other
Homebrew
brew
86359c4c91d8b4d2934828129a8de9cd310adf01.json
Implement `Homebrew.args` compatibility layer.
Library/Homebrew/compat/dependencies_helpers.rb
@@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require "cli/args" + +module DependenciesHelpers + module Compat + def argv_includes_ignores(argv = nil) + unless @printed_includes_ignores_warning + odeprecated "Homebrew.argv_includes_ignores", "Homebrew.args_includes_ignores" + @printed_includes_ignores_warning = true + end + args_includes_ignores(argv ? Homebrew::CLI::Args.new : Homebrew.args) + end + end + + prepend Compat +end
true
Other
Homebrew
brew
754beb64fc72fcf7ee249c05e13bacbeafafaa35.json
rubocop: exclude formula.rb from ClassLength. We want to allow this class to grow larger still while still enforcing this on other classes.
Library/.rubocop.yml
@@ -161,7 +161,6 @@ Lint/AmbiguousRegexpLiteral: Lint/ParenthesesAsGroupedExpression: Enabled: false - # most metrics don't make sense to apply for formulae/taps Metrics/AbcSize: Enabled: false
true
Other
Homebrew
brew
754beb64fc72fcf7ee249c05e13bacbeafafaa35.json
rubocop: exclude formula.rb from ClassLength. We want to allow this class to grow larger still while still enforcing this on other classes.
Library/.rubocop_cask.yml
@@ -20,6 +20,8 @@ Cask/StanzaOrder: Description: 'Ensure that cask stanzas are sorted correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/CONTRIBUTING.md#stanza-order' Enabled: true -# don't want this for casks but re-enabled for Library/Homebrew +# don't want these for casks but re-enabled for Library/Homebrew Style/FrozenStringLiteralComment: Enabled: false +Metrics/BlockLength: + Enabled: false
true
Other
Homebrew
brew
754beb64fc72fcf7ee249c05e13bacbeafafaa35.json
rubocop: exclude formula.rb from ClassLength. We want to allow this class to grow larger still while still enforcing this on other classes.
Library/Homebrew/.rubocop.yml
@@ -37,30 +37,33 @@ Lint/ParenthesesAsGroupedExpression: # TODO: try to bring down all metrics maximums Metrics/AbcSize: Enabled: true - Max: 275 + Max: 250 Metrics/BlockLength: Enabled: true - Max: 1100 + Max: 100 Exclude: - - 'test/formula_spec.rb' + - 'test/**/*' Metrics/BlockNesting: Enabled: true Max: 5 Metrics/ClassLength: Enabled: true - Max: 1400 + Max: 800 + Exclude: + - 'formula.rb' + - 'formula_installer.rb' Metrics/CyclomaticComplexity: Enabled: true - Max: 85 + Max: 80 Metrics/MethodLength: Enabled: true - Max: 300 + Max: 260 Metrics/ModuleLength: Enabled: true - Max: 550 + Max: 500 Metrics/PerceivedComplexity: Enabled: true - Max: 100 + Max: 80 # we won't change backward compatible predicate names Naming/PredicateName:
true
Other
Homebrew
brew
acfdbce6d4259f9b6440f606f1dc48d4497d8393.json
tap-new: update GitHub Actions. This should be using the split options for a better user experience and can use both Linux and macOS now.
Library/Homebrew/dev-cmd/tap-new.rb
@@ -53,23 +53,37 @@ def tap_new pull_request: [] jobs: test-bot: - runs-on: macos-latest + runs-on: [ubuntu-latest, macos-latest] steps: + - name: Update Homebrew + run: brew update + - name: Set up Git repository uses: actions/checkout@v2 - - name: Run brew test-bot + + - name: Set up Homebrew run: | - set -e - brew update HOMEBREW_TAP_DIR="/usr/local/Homebrew/Library/Taps/#{tap.full_name}" mkdir -p "$HOMEBREW_TAP_DIR" rm -rf "$HOMEBREW_TAP_DIR" ln -s "$PWD" "$HOMEBREW_TAP_DIR" - brew test-bot + + - name: Run brew test-bot --only-cleanup-before + run: brew test-bot --only-cleanup-before + + - name: Run brew test-bot --only-setup + run: brew test-bot --only-setup + + - name: Run brew test-bot --only-tap-syntax + run: brew test-bot --only-tap-syntax + + - name: Run brew test-bot --only-formulae + if: github.event_name == 'pull_request' + run: brew test-bot --only-formulae YAML (tap.path/".github/workflows").mkpath - write_path(tap, ".github/workflows/main.yml", actions) + write_path(tap, ".github/workflows/tests.yml", actions) ohai "Created #{tap}" puts tap.path.to_s end
true
Other
Homebrew
brew
acfdbce6d4259f9b6440f606f1dc48d4497d8393.json
tap-new: update GitHub Actions. This should be using the split options for a better user experience and can use both Linux and macOS now.
Library/Homebrew/test/dev-cmd/tap-new_spec.rb
@@ -7,13 +7,13 @@ end describe "brew tap-new", :integration_test do - it "initializes a new Tap with a ReadMe file and GitHub Actions CI" do + it "initializes a new tap with a README file and GitHub Actions CI" do expect { brew "tap-new", "homebrew/foo", "--verbose" } .to be_a_success .and output(%r{homebrew/foo}).to_stdout .and not_to_output.to_stderr expect(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md").to exist - expect(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/.github/workflows/main.yml").to exist + expect(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/.github/workflows/tests.yml").to exist end end
true
Other
Homebrew
brew
94274f7ffcbf394f59cb67203526129d43970fd4.json
docs/Formula-Cookbook: improve license text. Co-authored-by: Jonathan Chang <jchang641@gmail.com>
docs/Formula-Cookbook.md
@@ -91,7 +91,9 @@ Try to summarise from the [`homepage`](https://rubydoc.brew.sh/Formula#homepage% **We don’t accept new formulae into Homebrew/homebrew-core without a [`license`](https://rubydoc.brew.sh/Formula#license-class_method)!** -Find the license identifier from the [SPDX License List](https://spdx.org/licenses/) (or `:public_domain` for software in the public domain). We only accept licenses from this list that are a [Debian Free Software Guidelines license](https://wiki.debian.org/DFSGLicenses) (or public domain based on [the Debian Free Software Guidelines on Public Domain software](https://wiki.debian.org/DFSGLicenses#Public_Domain)). +We only accept formulae that use a [Debian Free Software Guidelines license](https://wiki.debian.org/DFSGLicenses) or are released into the public domain following [DFSG Guidelines on Public Domain software](https://wiki.debian.org/DFSGLicenses#Public_Domain). + +Use the license identifier from the [SPDX License List](https://spdx.org/licenses/) e.g. `license "BSD-2-Clause"`, or use `license :public_domain` for public domain software. If the software is available under multiple licenses, you should list them all in an array:
false
Other
Homebrew
brew
281a5986856f3505c23b45c786b5e98ec1643f07.json
cmd/uses: extract function `intersection_of_dependents`
Library/Homebrew/cmd/uses.rb
@@ -65,15 +65,25 @@ def uses end use_runtime_dependents = args.installed? && + !used_formulae_missing && !args.include_build? && !args.include_test? && !args.include_optional? && !args.skip_recommended? + uses = intersection_of_dependents(use_runtime_dependents, used_formulae, args: args) + + return if uses.empty? + + puts Formatter.columns(uses.map(&:full_name).sort) + odie "Missing formulae should not have dependents!" if used_formulae_missing + end + + def intersection_of_dependents(use_runtime_dependents, used_formulae, args:) recursive = args.recursive? includes, ignores = args_includes_ignores(args) - uses = if use_runtime_dependents && !used_formulae_missing + if use_runtime_dependents used_formulae.map(&:runtime_installed_formula_dependents) .reduce(&:&) .select(&:any_version_installed?) + @@ -87,11 +97,6 @@ def uses select_used_dependents(deps, used_formulae, recursive, includes, ignores) end - - return if uses.empty? - - puts Formatter.columns(uses.map(&:full_name).sort) - odie "Missing formulae should not have dependents!" if used_formulae_missing end def select_used_dependents(dependents, used_formulae, recursive, includes, ignores)
false
Other
Homebrew
brew
7e47d1be94d02522057554cca73d77a41c3395ce.json
cmd/log: fix args error
Library/Homebrew/cmd/log.rb
@@ -37,7 +37,7 @@ def log ENV["PATH"] = ENV["HOMEBREW_PATH"] if args.no_named? - git_log HOMEBREW_REPOSITORY + git_log HOMEBREW_REPOSITORY, args: args else path = Formulary.path(args.named.first) tap = Tap.from_path(path)
false
Other
Homebrew
brew
4cfd80451a28977a8621fcedfd2ffdcc9f82f734.json
deps: fix args for --installed with no formula
Library/Homebrew/cmd/deps.rb
@@ -96,7 +96,7 @@ def deps if args.no_named? raise FormulaUnspecifiedError unless args.installed? - puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive + puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive, args: args return end
false
Other
Homebrew
brew
1173d00bf6316fa4ce98a46a1fcbe9d120d75dcc.json
Add links for determining more restrictive license
docs/Formula-Cookbook.md
@@ -99,7 +99,7 @@ If the software is available under multiple licenses, you should list them all i license ["MIT", "GPL-2.0"] ``` -Note: only specify multiple licenses if the formula gives the user a choice between the licenses. Formulae that have different licenses for different parts of their software should specify only the more restrictive license. +Note: only specify multiple licenses if the formula gives the user a choice between the licenses. Formulae that have different licenses for different parts of their software should specify only the more restrictive license. For help determining which license is more restrictive, take a look [https://choosealicense.com](https://choosealicense.com/licenses/) or the [Comparison of free and open-source software licences Wikipedia page](https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licences). ### Check the build system
false
Other
Homebrew
brew
7c6cd247ee8f1eae426ba61c7bfa9ea3b4c91a33.json
Apply suggestions from code review Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
docs/Formula-Cookbook.md
@@ -89,11 +89,11 @@ Try to summarise from the [`homepage`](https://rubydoc.brew.sh/Formula#homepage% ### Fill in the `license` -**We don’t accept formulae without a [`license`](https://rubydoc.brew.sh/Formula#license-class_method)!** +**We don’t accept new formulae into Homebrew/homebrew-core without a [`license`](https://rubydoc.brew.sh/Formula#license-class_method)!** -Find the license identifier from the [SPDX License List](https://spdx.org/licenses/). We only accept licenses from this list. +Find the license identifier from the [SPDX License List](https://spdx.org/licenses/). We only accept licenses from this list that are a [Debian Free Software Guidelines license](https://wiki.debian.org/DFSGLicenses). -If the formula gives the user the option to choose which license to use, you should list them all in an array: +If the software is available under multiple licenses, you should list them all in an array: ```ruby license ["MIT", "GPL-2.0"]
false
Other
Homebrew
brew
b57b83feeccbfd1435e018a5a79328a2313078e8.json
dev-cmd/ruby: improve args passing
Library/Homebrew/dev-cmd/ruby.rb
@@ -13,21 +13,26 @@ def ruby_args Run a Ruby instance with Homebrew's libraries loaded, e.g. `brew ruby -e "puts :gcc.f.deps"` or `brew ruby script.rb`. EOS - switch "-r", - description: "Load a library using `require`." - switch "-e", - description: "Execute the given text string as a script." + flag "-r=", + description: "Load a library using `require`." + flag "-e=", + description: "Execute the given text string as a script." end end def ruby - ruby_args.parse + args = ruby_args.parse + + ruby_sys_args = [] + ruby_sys_args << "-r#{args.r}" if args.r + ruby_sys_args << "-e #{args.e}" if args.e + ruby_sys_args += args.named begin safe_system RUBY_PATH, "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), "-rglobal", "-rdev-cmd/irb", - *ARGV + *ruby_sys_args rescue ErrorDuringExecution => e exit e.status.exitstatus end
false
Other
Homebrew
brew
25009f94e72ee69e982e832c15e8a8e27893d999.json
cmd/list: remove ARGV usage
Library/Homebrew/cmd/list.rb
@@ -165,7 +165,7 @@ def filtered_list(args:) def list_casks(args:) cask_list = Cask::Cmd::List.new args.named - cask_list.one = ARGV.include? "-1" + cask_list.one = args.public_send(:'1?') cask_list.versions = args.versions? cask_list.full_name = args.full_name? cask_list.run
false
Other
Homebrew
brew
10f2a5025621aed308122880d0796e8a7b713bb9.json
dev-cmd/prof: improve arg passing
Library/Homebrew/dev-cmd/prof.rb
@@ -8,20 +8,19 @@ module Homebrew def prof_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `prof` <command> + `prof` [<command>] Run Homebrew with the Ruby profiler, e.g. `brew prof readall`. EOS - min_named 1 end end def prof - prof_args.parse + args = prof_args.parse Homebrew.install_gem_setup_path! "ruby-prof", version: "0.18.0" FileUtils.mkdir_p "prof" brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path - safe_system "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *ARGV + safe_system "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *args.named end end
true
Other
Homebrew
brew
10f2a5025621aed308122880d0796e8a7b713bb9.json
dev-cmd/prof: improve arg passing
docs/Manpage.md
@@ -966,7 +966,7 @@ Apply the bottle commit and publish bottles to Bintray. * `--root-url`: Use the specified *`URL`* as the root of the bottle's URL instead of Homebrew's default. -### `prof` *`command`* +### `prof` [*`command`*] Run Homebrew with the Ruby profiler, e.g. `brew prof readall`.
true
Other
Homebrew
brew
10f2a5025621aed308122880d0796e8a7b713bb9.json
dev-cmd/prof: improve arg passing
manpages/brew-cask.1
@@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW\-CASK" "1" "July 2020" "Homebrew" "brew-cask" +.TH "BREW\-CASK" "1" "August 2020" "Homebrew" "brew-cask" . .SH "NAME" \fBbrew\-cask\fR \- a friendly binary installer for macOS
true
Other
Homebrew
brew
10f2a5025621aed308122880d0796e8a7b713bb9.json
dev-cmd/prof: improve arg passing
manpages/brew.1
@@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "July 2020" "Homebrew" "brew" +.TH "BREW" "1" "August 2020" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The Missing Package Manager for macOS @@ -1285,7 +1285,7 @@ Upload to the specified Bintray organisation (default: \fBhomebrew\fR)\. \fB\-\-root\-url\fR Use the specified \fIURL\fR as the root of the bottle\'s URL instead of Homebrew\'s default\. . -.SS "\fBprof\fR \fIcommand\fR" +.SS "\fBprof\fR [\fIcommand\fR]" Run Homebrew with the Ruby profiler, e\.g\. \fBbrew prof readall\fR\. . .SS "\fBrelease\-notes\fR [\fIoptions\fR] [\fIprevious_tag\fR] [\fIend_ref\fR]"
true
Other
Homebrew
brew
bcc4f1bb292698c1ba3fbad5720706ddd123fbd0.json
version: disallow nil value for Token#create
Library/Homebrew/version.rb
@@ -13,9 +13,6 @@ class Token include Comparable def self.create(val) - return NULL_TOKEN if val.nil? - return NULL_TOKEN if val.respond_to?(:null?) && val.null? - raise TypeError, "Token value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str) case val
false
Other
Homebrew
brew
144a454e3487a75c68759eb5035a8c8ac41082f0.json
test/version_spec: add special token comparison examples
Library/Homebrew/test/version_spec.rb
@@ -16,6 +16,28 @@ specify "#to_s" do expect(described_class.new("foo").to_s).to eq("foo") end + + it "can be compared against nil" do + expect(described_class.create("2")).to be > nil + expect(described_class.create("p194")).to be > nil + end + + it "can be compared against Version::NULL_TOKEN" do + expect(described_class.create("2")).to be > Version::NULL_TOKEN + expect(described_class.create("p194")).to be > Version::NULL_TOKEN + end + + it "can be compared against strings" do + expect(described_class.create("2")).to be == "2" + expect(described_class.create("p194")).to be == "p194" + expect(described_class.create("1")).to be == 1 + end + + specify "comparison returns nil for non-token" do + v = described_class.create("1") + expect(v <=> Object.new).to be nil + expect { v > Object.new }.to raise_error(ArgumentError) + end end describe Version::NULL do
false
Other
Homebrew
brew
9fb3a80e383f11e94e763cae048efecaf87a52d3.json
Add cloudformation-cli to blocklist
Library/Homebrew/utils/pypi.rb
@@ -8,6 +8,7 @@ module PyPI AUTOMATIC_RESOURCE_UPDATE_BLOCKLIST = %w[ ansible ansible@2.8 + cloudformation-cli diffoscope dxpy molecule
false
Other
Homebrew
brew
1b3ae7f9e68a43fdb56d5a3d05a4b520edc7684b.json
Remove unused `BottlePublisher` class.
Library/Homebrew/bottle_publisher.rb
@@ -1,160 +0,0 @@ -# frozen_string_literal: true - -require "utils" -require "formula_info" - -class BottlePublisher - def initialize(tap, changed_formulae_names, bintray_org, no_publish, warn_on_publish_failure) - @tap = tap - @changed_formulae_names = changed_formulae_names - @no_publish = no_publish - @bintray_org = bintray_org - @warn_on_publish_failure = warn_on_publish_failure - end - - def publish_and_check_bottles - # Formulae with affected bottles that were published - bintray_published_formulae = [] - - # Publish bottles on Bintray - unless @no_publish - published = publish_changed_formula_bottles - bintray_published_formulae.concat(published) - end - - # Verify bintray publishing after all patches have been applied - bintray_published_formulae.uniq! - verify_bintray_published(bintray_published_formulae) - end - - def publish_changed_formula_bottles - raise "Need to load formulae to publish them!" if Homebrew::EnvConfig.disable_load_formula? - - published = [] - bintray_creds = { user: Homebrew::EnvConfig.bintray_user, key: Homebrew::EnvConfig.bintray_key } - if bintray_creds[:user] && bintray_creds[:key] - @changed_formulae_names.each do |name| - f = Formula[name] - next if f.bottle_unneeded? || f.bottle_disabled? - - bintray_org = @bintray_org || @tap.user.downcase - next unless publish_bottle_file_on_bintray(f, bintray_org, bintray_creds) - - published << f.full_name - end - else - opoo "You must set HOMEBREW_BINTRAY_USER and HOMEBREW_BINTRAY_KEY to add or update bottles on Bintray!" - end - published - end - - # Publishes the current bottle files for a given formula to Bintray - def publish_bottle_file_on_bintray(f, bintray_org, creds) - repo = Utils::Bottles::Bintray.repository(f.tap) - package = Utils::Bottles::Bintray.package(f.name) - info = FormulaInfo.lookup(f.full_name) - raise "Failed publishing bottle: failed reading formula info for #{f.full_name}" if info.nil? - - unless info.bottle_info_any - opoo "No bottle defined in formula #{package}" - return false - end - version = info.pkg_version - ohai "Publishing on Bintray: #{package} #{version}" - curl "--write-out", '\n', "--silent", "--fail", - "--user", "#{creds[:user]}:#{creds[:key]}", "--request", "POST", - "--header", "Content-Type: application/json", - "--data", '{"publish_wait_for_secs": 0}', - "https://api.bintray.com/content/#{bintray_org}/#{repo}/#{package}/#{version}/publish" - true - rescue => e - raise unless @warn_on_publish_failure - - onoe e - false - end - - # Verifies that formulae have been published on Bintray by downloading a bottle file - # for each one. Blocks until the published files are available. - # Raises an error if the verification fails. - # This does not currently work for `brew pull`, because it may have cached the old - # version of a formula. - def verify_bintray_published(formulae_names) - return if formulae_names.empty? - - raise "Need to load formulae to verify their publication!" if Homebrew::EnvConfig.disable_load_formula? - - ohai "Verifying bottles published on Bintray" - formulae = formulae_names.map { |n| Formula[n] } - max_retries = 300 # shared among all bottles - poll_retry_delay_seconds = 2 - - HOMEBREW_CACHE.cd do - formulae.each do |f| - retry_count = 0 - wrote_dots = false - # Choose arbitrary bottle just to get the host/port for Bintray right - jinfo = FormulaInfo.lookup(f.full_name) - unless jinfo - opoo "Cannot publish bottle: Failed reading info for formula #{f.full_name}" - next - end - bottle_info = jinfo.bottle_info_any - unless bottle_info - opoo "No bottle defined in formula #{f.full_name}" - next - end - - # Poll for publication completion using a quick partial HEAD, to avoid spurious error messages - # 401 error is normal while file is still in async publishing process - url = URI(bottle_info["url"]) - puts "Verifying bottle: #{File.basename(url.path)}" - http = Net::HTTP.new(url.host, url.port) - http.use_ssl = true - retry_count = 0 - http.start do - loop do - req = Net::HTTP::Head.new url - req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY - res = http.request req - break if res.is_a?(Net::HTTPSuccess) || res.code == "302" - - unless res.is_a?(Net::HTTPClientError) - raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!" - end - - raise "Failed to find published #{f} bottle at #{url}!" if retry_count >= max_retries - - print(wrote_dots ? "." : "Waiting on Bintray.") - wrote_dots = true - sleep poll_retry_delay_seconds - retry_count += 1 - end - end - - # Actual download and verification - # We do a retry on this, too, because sometimes the external curl will fail even - # when the prior HEAD has succeeded. - puts "\n" if wrote_dots - filename = File.basename(url.path) - curl_retry_delay_seconds = 4 - max_curl_retries = 1 - retry_count = 0 - # We're in the cache; make sure to force re-download - loop do - curl_download url, to: filename - break - rescue - raise "Failed to download #{f} bottle from #{url}!" if retry_count >= max_curl_retries - - puts "curl download failed; retrying in #{curl_retry_delay_seconds} sec" - sleep curl_retry_delay_seconds - curl_retry_delay_seconds *= 2 - retry_count += 1 - end - checksum = Checksum.new(:sha256, bottle_info["sha256"]) - Pathname.new(filename).verify_checksum(checksum) - end - end - end -end
true
Other
Homebrew
brew
1b3ae7f9e68a43fdb56d5a3d05a4b520edc7684b.json
Remove unused `BottlePublisher` class.
Library/Homebrew/sorbet/files.yaml
@@ -1,6 +1,5 @@ false: - ./bintray.rb - - ./bottle_publisher.rb - ./brew.rb - ./build.rb - ./cask/artifact/abstract_artifact.rb @@ -268,7 +267,6 @@ false: - ./test.rb - ./test/ENV_spec.rb - ./test/bintray_spec.rb - - ./test/bottle_publisher_spec.rb - ./test/cask_dependent_spec.rb - ./test/cask/artifact/alt_target_spec.rb - ./test/cask/artifact/app_spec.rb
true
Other
Homebrew
brew
1b3ae7f9e68a43fdb56d5a3d05a4b520edc7684b.json
Remove unused `BottlePublisher` class.
Library/Homebrew/test/bottle_publisher_spec.rb
@@ -1,48 +0,0 @@ -# frozen_string_literal: true - -require "bottle_publisher" - -describe BottlePublisher do - subject(:bottle_publisher) { - described_class.new( - CoreTap.instance, ["#{CoreTap.instance.name}/hello.rb"], "homebrew", false, false - ) - } - - let(:tap) { CoreTap.new } - - describe "publish_and_check_bottles" do - it "fails if HOMEBREW_DISABLE_LOAD_FORMULA is set to 1" do - ENV["HOMEBREW_DISABLE_LOAD_FORMULA"] = "1" - expect { bottle_publisher.publish_and_check_bottles } - .to raise_error("Need to load formulae to publish them!") - end - - it "returns nil because HOMEBREW_BINTRAY_USER and HOMEBREW_BINTRAY_KEY are not set" do - ENV["HOMEBREW_BINTRAY_USER"] = nil - ENV["HOMEBREW_BINTRAY_KEY"] = nil - expect(bottle_publisher.publish_and_check_bottles) - .to eq nil - end - end - - describe "verify_bintray_published" do - it "returns nil if no formula has been defined" do - expect(bottle_publisher.verify_bintray_published([])) - .to eq nil - end - - it "fails if HOMEBREW_DISABLE_LOAD_FORMULA is set to 1" do - ENV["HOMEBREW_DISABLE_LOAD_FORMULA"] = "1" - stub_formula_loader(formula("foo") { url "foo-1.0" }) - expect { bottle_publisher.verify_bintray_published(["foo"]) } - .to raise_error("Need to load formulae to verify their publication!") - end - - it "checks if a bottle has been published" do - stub_formula_loader(formula("foo") { url "foo-1.0" }) - expect { bottle_publisher.verify_bintray_published(["foo"]) } - .to output("Warning: Cannot publish bottle: Failed reading info for formula foo\n").to_stderr - end - end -end
true
Other
Homebrew
brew
97e05ae4106bc7315233d9d35f8d02e913378b1a.json
cmd/outdated: restore sorting of formulae
Library/Homebrew/cmd/outdated.rb
@@ -189,7 +189,7 @@ def outdated_formulae_casks(args:) casks = Cask::Caskroom.casks end - [select_outdated(formulae, args: args), select_outdated(casks, args: args)] + [select_outdated(formulae, args: args).sort, select_outdated(casks, args: args)] end def select_outdated(formulae_or_casks, args:)
false
Other
Homebrew
brew
39f000c6ab7cffe661549aec1d3651502b339957.json
bump-formula-pr: restore formula unless read only run
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -246,7 +246,8 @@ def bump_formula_pr ] end - old_contents = File.read(formula.path) unless args.dry_run? + read_only_run = args.dry_run? && !args.write? + old_contents = File.read(formula.path) unless read_only_run if new_mirrors replacement_pairs << [ @@ -310,13 +311,13 @@ def bump_formula_pr end if new_formula_version < old_formula_version - formula.path.atomic_write(old_contents) unless args.dry_run? + formula.path.atomic_write(old_contents) unless read_only_run odie <<~EOS You need to bump this formula manually since changing the version from #{old_formula_version} to #{new_formula_version} would be a downgrade. EOS elsif new_formula_version == old_formula_version - formula.path.atomic_write(old_contents) unless args.dry_run? + formula.path.atomic_write(old_contents) unless read_only_run odie <<~EOS You need to bump this formula manually since the new version and old version are both #{new_formula_version}. @@ -330,7 +331,7 @@ def bump_formula_pr end ohai "brew update-python-resources #{formula.name}" - if !args.dry_run? || (args.dry_run? && args.write?) + unless read_only_run PyPI.update_python_resources! formula, new_formula_version, silent: true, ignore_non_pypi_packages: true end @@ -450,7 +451,8 @@ def forked_repo_info(formula, tap_full_name, old_contents) end def inreplace_pairs(path, replacement_pairs, args:) - if args.dry_run? + read_only_run = args.dry_run? && !args.write? + if read_only_run str = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } contents = StringInreplaceExtension.new(str) replacement_pairs.each do |old, new|
false
Other
Homebrew
brew
5e98d4df088128d32036bc2518db754714aa6f81.json
cli/parser: restore env setting for global options
Library/Homebrew/cli/parser.rb
@@ -49,7 +49,7 @@ def initialize(&block) @formula_options = false self.class.global_options.each do |short, long, desc| - switch short, long, description: desc + switch short, long, description: desc, env: option_to_name(long) end instance_eval(&block) if block_given?
false
Other
Homebrew
brew
c494789d700fbb76035c2cd5d8c92cbe3ef2c0b0.json
list: pass args properly
Library/Homebrew/cmd/list.rb
@@ -53,7 +53,7 @@ def list_args def list args = list_args.parse - return list_casks if args.cask? + return list_casks(args: args) if args.cask? return list_unbrewed if args.unbrewed? @@ -66,7 +66,7 @@ def list end if args.pinned? || args.versions? - filtered_list + filtered_list args: args elsif args.no_named? if args.full_name? full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison) @@ -134,7 +134,7 @@ def list_unbrewed safe_system "find", *arguments end - def filtered_list + def filtered_list(args:) names = if args.no_named? Formula.racks else @@ -163,7 +163,7 @@ def filtered_list end end - def list_casks + def list_casks(args:) cask_list = Cask::Cmd::List.new args.named cask_list.one = ARGV.include? "-1" cask_list.versions = args.versions?
false
Other
Homebrew
brew
59b9d80ebd526ce8ee15df199f2a52148e7752b5.json
bump-formula-pr: add args to check_all_pull_requests
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -128,7 +128,7 @@ def bump_formula_pr check_open_pull_requests(formula, tap_full_name, args: args) new_version = args.version - check_all_pull_requests(formula, tap_full_name, version: new_version) if new_version + check_all_pull_requests(formula, tap_full_name, version: new_version, args: args) if new_version requested_spec = :stable formula_spec = formula.stable @@ -159,10 +159,10 @@ def bump_formula_pr old_version = old_formula_version.to_s forced_version = new_version.present? new_url_hash = if new_url && new_hash - check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version + check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version true elsif new_tag && new_revision - check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version + check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version false elsif !hash_type odie "#{formula}: no --tag= or --version= argument specified!" if !new_tag && !new_version @@ -173,7 +173,7 @@ def bump_formula_pr and old tag are both #{new_tag}. EOS end - check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version + check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag) new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD") new_revision = new_revision.strip @@ -190,7 +190,7 @@ def bump_formula_pr #{new_url} EOS end - check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version + check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version resource_path, forced_version = fetch_resource(formula, new_version, new_url) tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ] if tar_file_extensions.any? { |extension| new_url.include? extension } @@ -502,7 +502,7 @@ def check_open_pull_requests(formula, tap_full_name, args:) check_for_duplicate_pull_requests(pull_requests, args: args) end - def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil) + def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil, args:) unless version specs = {} specs[:tag] = tag if tag
false
Other
Homebrew
brew
465a1faa8a41156d0992af1b02c299a061d47d71.json
docs: add reference to update-python-resources
docs/Python-for-Formula-Authors.md
@@ -26,7 +26,9 @@ Applications should be installed into a Python [virtualenv](https://virtualenv.p All of the Python module dependencies of the application (and their dependencies, recursively) should be declared as `resource`s in the formula and installed into the virtualenv, as well. Each dependency should be explicitly specified; please do not rely on `setup.py` or `pip` to perform automatic dependency resolution, for the [reasons described here](Acceptable-Formulae.md#we-dont-like-install-scripts-that-download-unversioned-things). -You can use [homebrew-pypi-poet](https://pypi.python.org/pypi/homebrew-pypi-poet) to help you write resource stanzas. To use it, set up a virtualenv and install your package and all its dependencies. Then, `pip install homebrew-pypi-poet` into the same virtualenv. Running `poet some_package` will generate the necessary resource stanzas. You can do this like: +You can use `brew update-python-resources` to help you write resource stanzas. To use it, simply run `brew update-python-resources <formula>`. Sometimes, `brew update-python-resources` won't be able to automatically update the resources. If this happens, try running `brew update-python-resources --print-only <formula>` to print the resource stanzas instead of applying the changes directly to the file. You can then copy and paste resources as needed. + +If using `brew update-python-resources` doesn't work, you can use [homebrew-pypi-poet](https://pypi.python.org/pypi/homebrew-pypi-poet) to help you write resource stanzas. To use it, set up a virtualenv and install your package and all its dependencies. Then, `pip install homebrew-pypi-poet` into the same virtualenv. Running `poet some_package` will generate the necessary resource stanzas. You can do this like: ```sh # Install virtualenvwrapper
false
Other
Homebrew
brew
df5aac8b092f6552b065aa68c09e034b3e5e71e0.json
docs: add license information
docs/Formula-Cookbook.md
@@ -54,6 +54,7 @@ class Foo < Formula homepage "" url "https://example.com/foo-0.1.tar.gz" sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7" + license "" # depends_on "cmake" => :build @@ -86,6 +87,20 @@ An SSL/TLS (https) [`homepage`](https://rubydoc.brew.sh/Formula#homepage%3D-clas Try to summarise from the [`homepage`](https://rubydoc.brew.sh/Formula#homepage%3D-class_method) what the formula does in the [`desc`](https://rubydoc.brew.sh/Formula#desc%3D-class_method)ription. Note that the [`desc`](https://rubydoc.brew.sh/Formula#desc%3D-class_method)ription is automatically prepended with the formula name. +### Fill in the `license` + +**We don’t accept formulae without a [`license`](https://rubydoc.brew.sh/Formula#license-class_method)!** + +Find the license identifier from the [SPDX License List](https://spdx.org/licenses/). Note that we don't accept licenses that don't appear on the list. + +If the formula gives the user the option to choose which license to use, you should list them all in an array: + +```ruby +license ["MIT", "GPL-2.0"] +``` + +Note: only specify multiple licenses if the formula gives the user a choice between the licenses. Formulae that have different licenses for different parts of their software should specify only the more restrictive license. + ### Check the build system ```sh
false
Other
Homebrew
brew
57cac495594aa36544e8ec5749cf66c5f918de2d.json
Use formula.full_name for blocklist
Library/Homebrew/utils/pypi.rb
@@ -47,7 +47,7 @@ def get_pypi_info(package, version) def update_python_resources!(formula, version = nil, print_only: false, silent: false, ignore_non_pypi_packages: false) - if !print_only && AUTOMATIC_RESOURCE_UPDATE_BLOCKLIST.include?(formula.name) + if !print_only && AUTOMATIC_RESOURCE_UPDATE_BLOCKLIST.include?(formula.full_name) odie "The resources for \"#{formula.name}\" need special attention. Please update them manually." return end
false
Other
Homebrew
brew
7f158df8420d574e4bcb2228f3c9c2b845a739cd.json
extend/pathname: use absolute path to java in write_jar_script
Library/Homebrew/extend/pathname.rb
@@ -374,8 +374,11 @@ def env_script_all_files(dst, env) # Writes an exec script that invokes a Java jar def write_jar_script(target_jar, script_name, java_opts = "", java_version: nil) - (self/script_name).write_env_script "java", "#{java_opts} -jar \"#{target_jar}\"", - Language::Java.overridable_java_home_env(java_version) + (self/script_name).write <<~EOS + #!/bin/bash + export JAVA_HOME="#{Language::Java.overridable_java_home_env(java_version)[:JAVA_HOME]}" + exec "${JAVA_HOME}/bin/java" #{java_opts} -jar "#{target_jar}" "$@" + EOS end def install_metafiles(from = Pathname.pwd)
false
Other
Homebrew
brew
17d0a46afd931a565eb38087ad27866e6f01abbd.json
.gitignore: add sorbet and tapioca dependencies
.gitignore
@@ -86,11 +86,13 @@ **/vendor/bundle/ruby/*/gems/byebug-*/ **/vendor/bundle/ruby/*/gems/coderay-*/ **/vendor/bundle/ruby/*/gems/colorize-*/ +**/vendor/bundle/ruby/*/gems/commander-*/ **/vendor/bundle/ruby/*/gems/connection_pool-*/ **/vendor/bundle/ruby/*/gems/codecov-*/ **/vendor/bundle/ruby/*/gems/diff-lcs-*/ **/vendor/bundle/ruby/*/gems/docile-*/ **/vendor/bundle/ruby/*/gems/domain_name-*/ +**/vendor/bundle/ruby/*/gems/highline-*/ **/vendor/bundle/ruby/*/gems/http-cookie-*/ **/vendor/bundle/ruby/*/gems/hpricot-*/ **/vendor/bundle/ruby/*/gems/jaro_winkler-*/ @@ -107,6 +109,7 @@ **/vendor/bundle/ruby/*/gems/ntlm-http-*/ **/vendor/bundle/ruby/*/gems/parallel-*/ **/vendor/bundle/ruby/*/gems/parallel_tests-*/ +**/vendor/bundle/ruby/*/gems/parlour-*/ **/vendor/bundle/ruby/*/gems/parser-*/ **/vendor/bundle/ruby/*/gems/powerpack-*/ **/vendor/bundle/ruby/*/gems/psych-*/
false
Other
Homebrew
brew
e8dbbc2975d6a305aa0d3017b5911d217266d3eb.json
sorbet: update hidden definitions
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -13549,6 +13549,94 @@ module ParallelTests WINDOWS = ::T.let(nil, ::T.untyped) end +class Parlour::ConflictResolver + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +module Parlour::Debugging::Tree + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +module Parlour::Debugging + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::DetachedRbiGenerator + def detached!(*args, &blk); end +end + +class Parlour::DetachedRbiGenerator +end + +class Parlour::ParseError + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::Plugin + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::RbiGenerator::Namespace + def create_attr(*args, &blk); end +end + +class Parlour::RbiGenerator::Options + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::RbiGenerator::Parameter + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::RbiGenerator::RbiObject + def add_comments(*args, &blk); end +end + +class Parlour::RbiGenerator::RbiObject + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::RbiGenerator::StructProp + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::RbiGenerator + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +module Parlour::TypeLoader + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::TypeParser::IntermediateSig + def self.inherited(s); end +end + +class Parlour::TypeParser::NodePath + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Parlour::TypeParser + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + ParseError = Racc::ParseError Parser::CurrentRuby = Parser::Ruby26 @@ -18883,14 +18971,6 @@ end module RSpec::Its end -class RSpec::Mocks::AnyInstance::Recorder - include ::T::CompatibilityPatches::RSpecCompatibility::RecorderExtensions -end - -class RSpec::Mocks::MethodDouble - include ::T::CompatibilityPatches::RSpecCompatibility::MethodDoubleExtensions -end - class RSpec::Retry def attempts(); end @@ -21598,7 +21678,6 @@ module Stdenv def O3(); end def Os(); end - end class String @@ -21895,7 +21974,6 @@ module Superenv def O3(); end def Os(); end - end class SynchronizedDelegator @@ -22566,12 +22644,16 @@ end class Tapioca::Cli include ::Thor::Actions + def dsl(*constants); end + def generate(*gems); end def generator(); end def init(); end + def require(); end + def sync(); end def todo(); end @@ -22583,6 +22665,64 @@ end module Tapioca::Compilers end +module Tapioca::Compilers::Dsl +end + +class Tapioca::Compilers::Dsl::Base + def decorate(*args, &blk); end + + def gather_constants(*args, &blk); end + + def handles?(*args, &blk); end + + def initialize(*args, &blk); end + + def processable_constants(*args, &blk); end + SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped) +end + +class Tapioca::Compilers::Dsl::Base + extend ::T::Sig + extend ::T::Helpers + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +module Tapioca::Compilers::Dsl +end + +class Tapioca::Compilers::DslCompiler + def error_handler(*args, &blk); end + + def generators(*args, &blk); end + + def initialize(*args, &blk); end + + def requested_constants(*args, &blk); end + + def run(*args, &blk); end +end + +class Tapioca::Compilers::DslCompiler + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Tapioca::Compilers::RequiresCompiler + def compile(*args, &blk); end + + def initialize(*args, &blk); end +end + +class Tapioca::Compilers::RequiresCompiler + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + module Tapioca::Compilers::Sorbet SORBET = ::T.let(nil, ::T.untyped) end @@ -22607,6 +22747,7 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator def initialize(*args, &blk); end IGNORED_SYMBOLS = ::T.let(nil, ::T.untyped) SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped) + TYPE_PARAMETER_MATCHER = ::T.let(nil, ::T.untyped) end class Tapioca::Compilers::SymbolTable::SymbolGenerator @@ -22663,6 +22804,8 @@ class Tapioca::Config def generate_command(); end + def generators(); end + def initialize(*args, &blk); end def outdir(); end @@ -22676,13 +22819,16 @@ class Tapioca::Config def todos_path(); end def typed_overrides(); end - CONFIG_FILE_PATH = ::T.let(nil, ::T.untyped) - DEFAULT_OUTDIR = ::T.let(nil, ::T.untyped) + DEFAULT_DSLDIR = ::T.let(nil, ::T.untyped) + DEFAULT_GEMDIR = ::T.let(nil, ::T.untyped) DEFAULT_OVERRIDES = ::T.let(nil, ::T.untyped) DEFAULT_POSTREQUIRE = ::T.let(nil, ::T.untyped) DEFAULT_RBIDIR = ::T.let(nil, ::T.untyped) DEFAULT_TODOSPATH = ::T.let(nil, ::T.untyped) SORBET_CONFIG = ::T.let(nil, ::T.untyped) + SORBET_PATH = ::T.let(nil, ::T.untyped) + TAPIOCA_CONFIG = ::T.let(nil, ::T.untyped) + TAPIOCA_PATH = ::T.let(nil, ::T.untyped) end class Tapioca::Config @@ -22757,8 +22903,12 @@ class Tapioca::Gemfile end class Tapioca::Generator + def build_dsl(*args, &blk); end + def build_gem_rbis(*args, &blk); end + def build_requires(*args, &blk); end + def build_todos(*args, &blk); end def config(*args, &blk); end @@ -22778,6 +22928,8 @@ class Tapioca::Loader def initialize(*args, &blk); end def load_bundle(*args, &blk); end + + def load_rails(*args, &blk); end end class Tapioca::Loader @@ -22786,6 +22938,23 @@ class Tapioca::Loader extend ::T::Private::Methods::SingletonMethodHooks end +class Tapioca::SorbetConfig + def ignore(); end + + def initialize(*args, &blk); end + + def paths(*args, &blk); end +end + +class Tapioca::SorbetConfig + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks + def self.parse_file(*args, &blk); end + + def self.parse_string(*args, &blk); end +end + module Tapioca end
false
Other
Homebrew
brew
58848e402a66b9ca496346359db6525f01809371.json
sorbet/files.yaml: add new files
Library/Homebrew/sorbet/files.yaml
@@ -163,6 +163,7 @@ false: - ./dev-cmd/tests.rb - ./dev-cmd/unpack.rb - ./dev-cmd/update-license-data.rb + - ./dev-cmd/update-python-resources.rb - ./dev-cmd/update-test.rb - ./dev-cmd/vendor-gems.rb - ./development_tools.rb @@ -268,6 +269,7 @@ false: - ./test/ENV_spec.rb - ./test/bintray_spec.rb - ./test/bottle_publisher_spec.rb + - ./test/cask_dependent_spec.rb - ./test/cask/artifact/alt_target_spec.rb - ./test/cask/artifact/app_spec.rb - ./test/cask/artifact/binary_spec.rb @@ -823,11 +825,13 @@ false: - ./test/version_spec.rb - ./unpack_strategy/uncompressed.rb - ./utils/gems.rb + - ./utils/pypi.rb - ./version.rb true: - ./build_options.rb - ./cache_store.rb + - ./cask_dependent.rb - ./cask/cache.rb - ./cask/denylist.rb - ./cask/macos.rb
false
Other
Homebrew
brew
b08d1a28ad6c9c12b9f5bbc2cfa3a5df5df95d5c.json
update-python-resources: handle no sdist for package
Library/Homebrew/utils/pypi.rb
@@ -35,6 +35,8 @@ def get_pypi_info(package, version) end sdist = json["urls"].find { |url| url["packagetype"] == "sdist" } + return json["info"]["name"] if sdist.nil? + [json["info"]["name"], sdist["url"], sdist["digests"]["sha256"]] end
false
Other
Homebrew
brew
5efed5d8c54ca541791c8b9b6dd91b94ed3929b3.json
Remove debug message.
Library/Homebrew/dev-cmd/irb.rb
@@ -56,8 +56,6 @@ def irb require "keg" require "cask/all" - puts ARGV.inspect - ohai "Interactive Homebrew Shell" puts "Example commands available with: brew irb --examples" if args.pry?
false
Other
Homebrew
brew
b6a326f6ee28ffceba433a0c1ee13b3fba8e9909.json
Run `brew man` to update `brew bundle` manpage.
docs/Manpage.md
@@ -1194,6 +1194,8 @@ flags which will help find keg-only dependencies like `openssl`, `icu4c`, etc. Read the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout. * `--global`: Read the `Brewfile` from `~/.Brewfile`. +* `-v`, `--verbose`: + `install` prints output from commands as they are run. `check` lists all missing dependencies. * `--no-upgrade`: `install` won't run `brew upgrade` on outdated dependencies. Note they may still be upgraded by `brew install` if needed. * `-f`, `--force`:
true
Other
Homebrew
brew
b6a326f6ee28ffceba433a0c1ee13b3fba8e9909.json
Run `brew man` to update `brew bundle` manpage.
manpages/brew.1
@@ -1543,6 +1543,10 @@ Read the \fBBrewfile\fR from this location\. Use \fB\-\-file=\-\fR to pipe to st Read the \fBBrewfile\fR from \fB~/\.Brewfile\fR\. . .TP +\fB\-v\fR, \fB\-\-verbose\fR +\fBinstall\fR prints output from commands as they are run\. \fBcheck\fR lists all missing dependencies\. +. +.TP \fB\-\-no\-upgrade\fR \fBinstall\fR won\'t run \fBbrew upgrade\fR on outdated dependencies\. Note they may still be upgraded by \fBbrew install\fR if needed\. .
true
Other
Homebrew
brew
ce721f43a8d5976d9864a8b8df82494b58001553.json
display version data when formula is up-to-date
Library/Homebrew/dev-cmd/bump.rb
@@ -28,34 +28,34 @@ def bump requested_formula = Homebrew.args.formula requested_formula&.downcase! - raise FormulaUnavailableError, requested_formula if requested_formula && !get_formula_details(requested_formula) + raise FormulaUnavailableError, requested_formula if requested_formula && !validate_formula(requested_formula) - outdated_repology_packages = if requested_formula + repology_data = if requested_formula Repology.single_package_query(requested_formula) else Repology.parse_api_response end - if requested_formula && outdated_repology_packages.nil? - ohai "#{requested_formula} is up-to-date!" - puts "Current version: #{get_formula_details(requested_formula).version}" - return - end - - outdated_packages = Repology.validate_and_format_packages(outdated_repology_packages) - display(outdated_packages) + validated_formulae = Repology.validate_and_format_packages(repology_data) + display(validated_formulae) end - def get_formula_details(formula_name) + def validate_formula(formula_name) Formula[formula_name] rescue nil end - def display(outdated_packages) + def up_to_date?(package) + package[:current_formula_version] == package[:repology_latest_version] && + package[:current_formula_version] == package[:livecheck_latest_version] + end + + def display(formulae) puts - outdated_packages.each do |formula, package_details| - ohai formula + formulae.each do |formula, package_details| + title = (up_to_date?(package_details) ? formula + " is up to date!" : formula).to_s + ohai title puts "Current formula version: #{package_details[:current_formula_version]}" puts "Latest Repology version: #{package_details[:repology_latest_version]}" puts "Latest livecheck version: #{package_details[:livecheck_latest_version] || "Not found"}"
true
Other
Homebrew
brew
ce721f43a8d5976d9864a8b8df82494b58001553.json
display version data when formula is up-to-date
Library/Homebrew/utils/repology.rb
@@ -21,11 +21,11 @@ def single_package_query(name) output, _errors, _status = curl_output(url.to_s) data = JSON.parse(output) - outdated_homebrew = data.select do |repo| - repo["repo"] == "homebrew" && repo["status"] == "outdated" + homebrew = data.select do |repo| + repo["repo"] == "homebrew" end - outdated_homebrew.empty? ? nil : { name: data } + homebrew.empty? ? nil : { name: data } end def parse_api_response @@ -75,7 +75,7 @@ def validate_and_format_packages(outdated_repology_packages) end def format_package(package_name, latest_version) - formula = Formula[package_name] + formula = formula_data(package_name) return if formula.blank? @@ -95,4 +95,10 @@ def format_package(package_name, latest_version) open_pull_requests: pull_requests, } end + + def formula_data(package_name) + Formula[package_name] + rescue + nil + end end
true
Other
Homebrew
brew
e05538a7d9f50c821b5605deff534beed85b8a04.json
Create DependenciesHelpers file, add tests
Library/Homebrew/cmd/deps.rb
@@ -4,6 +4,7 @@ require "ostruct" require "cli/parser" require "cask/caskroom" +require "dependencies_helpers" module Homebrew extend DependenciesHelpers
true
Other
Homebrew
brew
e05538a7d9f50c821b5605deff534beed85b8a04.json
Create DependenciesHelpers file, add tests
Library/Homebrew/cmd/uses.rb
@@ -7,6 +7,7 @@ require "formula" require "cli/parser" require "cask/caskroom" +require "dependencies_helpers" module Homebrew extend DependenciesHelpers
true
Other
Homebrew
brew
e05538a7d9f50c821b5605deff534beed85b8a04.json
Create DependenciesHelpers file, add tests
Library/Homebrew/dependencies.rb
@@ -56,81 +56,3 @@ def inspect "#<#{self.class.name}: {#{to_a.join(", ")}}>" end end - -module DependenciesHelpers - def argv_includes_ignores(argv) - includes = [] - ignores = [] - - if argv.include? "--include-build" - includes << "build?" - else - ignores << "build?" - end - - if argv.include? "--include-test" - includes << "test?" - else - ignores << "test?" - end - - if argv.include? "--include-optional" - includes << "optional?" - else - ignores << "optional?" - end - - ignores << "recommended?" if args.skip_recommended? - - [includes, ignores] - end - - def recursive_includes(klass, root_dependent, includes, ignores) - type = if klass == Dependency - :dependencies - elsif klass == Requirement - :requirements - else - raise ArgumentError, "Invalid class argument: #{klass}" - end - - root_dependent.send("recursive_#{type}") do |dependent, dep| - if dep.recommended? - klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? || dep.test? - keep = false - keep ||= dep.test? && includes.include?("test?") && dependent == formula - keep ||= dep.build? && includes.include?("build?") - klass.prune unless keep - end - - # If a tap isn't installed, we can't find the dependencies of one of - # its formulae, and an exception will be thrown if we try. - if type == :dependencies && - dep.is_a?(TapDependency) && - !dep.tap.installed? - Dependency.keep_but_prune_recursive_deps - end - end - end - - def reject_ignores(dependables, ignores, includes) - dependables.reject do |dep| - next false unless ignores.any? { |ignore| dep.send(ignore) } - - includes.none? { |include| dep.send(include) } - end - end - - def dependents(formulae_or_casks) - formulae_or_casks.map do |formula_or_cask| - if formula_or_cask.is_a?(Formula) - formula_or_cask - else - CaskDependent.new(formula_or_cask) - end - end - end -end
true
Other
Homebrew
brew
e05538a7d9f50c821b5605deff534beed85b8a04.json
Create DependenciesHelpers file, add tests
Library/Homebrew/dependencies_helpers.rb
@@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require "cask_dependent" + +module DependenciesHelpers + def argv_includes_ignores(argv) + includes = [] + ignores = [] + + if argv.include? "--include-build" + includes << "build?" + else + ignores << "build?" + end + + if argv.include? "--include-test" + includes << "test?" + else + ignores << "test?" + end + + if argv.include? "--include-optional" + includes << "optional?" + else + ignores << "optional?" + end + + ignores << "recommended?" if args.skip_recommended? + + [includes, ignores] + end + + def recursive_includes(klass, root_dependent, includes, ignores) + type = if klass == Dependency + :dependencies + elsif klass == Requirement + :requirements + else + raise ArgumentError, "Invalid class argument: #{klass}" + end + + root_dependent.send("recursive_#{type}") do |dependent, dep| + if dep.recommended? + klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? || dep.test? + keep = false + keep ||= dep.test? && includes.include?("test?") && dependent == formula + keep ||= dep.build? && includes.include?("build?") + klass.prune unless keep + end + + # If a tap isn't installed, we can't find the dependencies of one of + # its formulae, and an exception will be thrown if we try. + if type == :dependencies && + dep.is_a?(TapDependency) && + !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps + end + end + end + + def reject_ignores(dependables, ignores, includes) + dependables.reject do |dep| + next false unless ignores.any? { |ignore| dep.send(ignore) } + + includes.none? { |include| dep.send(include) } + end + end + + def dependents(formulae_or_casks) + formulae_or_casks.map do |formula_or_cask| + if formula_or_cask.is_a?(Formula) + formula_or_cask + else + CaskDependent.new(formula_or_cask) + end + end + end + module_function :dependents +end
true
Other
Homebrew
brew
e05538a7d9f50c821b5605deff534beed85b8a04.json
Create DependenciesHelpers file, add tests
Library/Homebrew/test/dependencies_helpers_spec.rb
@@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require "dependencies_helpers" + +describe DependenciesHelpers do + specify "#dependents" do + foo = formula "foo" do + url "foo" + version "1.0" + end + + foo_cask = Cask::CaskLoader.load(+<<-RUBY) + cask "foo_cask" do + end + RUBY + + bar = formula "bar" do + url "bar-url" + version "1.0" + end + + bar_cask = Cask::CaskLoader.load(+<<-RUBY) + cask "bar-cask" do + end + RUBY + + methods = [ + :name, + :full_name, + :runtime_dependencies, + :deps, + :requirements, + :recursive_dependencies, + :recursive_requirements, + :any_version_installed?, + ] + + dependents = described_class.dependents([foo, foo_cask, bar, bar_cask]) + + dependents.each do |dependent| + methods.each do |method| + expect(dependent.respond_to?(method)) + .to be true + end + end + end +end
true
Other
Homebrew
brew
4381c32524c999fd7de308ef775c66b4f056497d.json
Add test for parsing with `ignore_invalid_options`.
Library/Homebrew/cli/args.rb
@@ -20,6 +20,7 @@ def initialize(argv = ARGV.dup.freeze, set_default_args: false) # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). self[:named_args] = argv.reject { |arg| arg.start_with?("-") } + self[:remaining] = [] # Set values needed before Parser#parse has been run. return unless set_default_args @@ -32,6 +33,11 @@ def initialize(argv = ARGV.dup.freeze, set_default_args: false) self[:universal?] = argv.include?("--universal") end + def freeze_remaining_args!(remaining_args) + self[:remaining] = remaining_args + self[:remaining].freeze + end + def freeze_named_args!(named_args) # Reset cache values reliant on named_args @formulae = nil
true
Other
Homebrew
brew
4381c32524c999fd7de308ef775c66b4f056497d.json
Add test for parsing with `ignore_invalid_options`.
Library/Homebrew/cli/parser.rb
@@ -156,9 +156,7 @@ def summary @parser.to_s end - def parse(argv = @argv, ignore_invalid_options: false) - raise "Arguments were already parsed!" if @args_parsed - + def parse_remaining(argv, ignore_invalid_options: false) i = 0 remaining = [] @@ -189,6 +187,14 @@ def parse(argv = @argv, ignore_invalid_options: false) i += 1 end + [remaining, non_options] + end + + def parse(argv = @argv, ignore_invalid_options: false) + raise "Arguments were already parsed!" if @args_parsed + + remaining, non_options = parse_remaining(argv, ignore_invalid_options: ignore_invalid_options) + named_args = if ignore_invalid_options [] else @@ -198,6 +204,7 @@ def parse(argv = @argv, ignore_invalid_options: false) check_constraint_violations check_named_args(named_args) @args.freeze_named_args!(named_args) + @args.freeze_remaining_args!(non_options.empty? ? remaining : [*remaining, "--", non_options]) @args.freeze_processed_options!(@processed_options) @args_parsed = true
true