From ad57705029b1dbcced63367475b2550c8e7f82a3 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Sat, 7 Jan 2023 21:22:47 -0800 Subject: [PATCH] All --cask for linux dev cmds This ability was removed around a month ago but needs to be added back in. Developers want to be able to use the `bump` and `audit` commands when on Linux. This is especially useful for CI. --- Library/Homebrew/cli/parser.rb | 12 +++++++----- Library/Homebrew/test/cli/parser_spec.rb | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index f2d58d1126..1a85f404df 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -122,8 +122,9 @@ module Homebrew @args = Homebrew::CLI::Args.new # Filter out Sorbet runtime type checking method calls. - @command_name = caller_locations.select { |location| location.path.exclude?("/gems/sorbet-runtime-") } - .second.label.chomp("_args").tr("_", "-") + cmd_location = caller_locations.select { |location| location.path.exclude?("/gems/sorbet-runtime-") }.second + @command_name = cmd_location.label.chomp("_args").tr("_", "-") + @is_dev_cmd = cmd_location.absolute_path.start_with?(Commands::HOMEBREW_DEV_CMD_PATH) @constraints = [] @conflicts = [] @@ -329,10 +330,11 @@ module Homebrew remaining + non_options end - set_default_options - unless ignore_invalid_options - validate_options + unless @is_dev_cmd + set_default_options + validate_options + end check_constraint_violations check_named_args(named_args) end diff --git a/Library/Homebrew/test/cli/parser_spec.rb b/Library/Homebrew/test/cli/parser_spec.rb index 8711931858..97b76decb7 100644 --- a/Library/Homebrew/test/cli/parser_spec.rb +++ b/Library/Homebrew/test/cli/parser_spec.rb @@ -577,6 +577,14 @@ describe Homebrew::CLI::Parser do .and not_to_output.to_stdout .and raise_exception SystemExit end + + # Developers want to be able to use `audit` and `bump` + # commands for formulae and casks on Linux. + it "succeeds for developer commands" do + require "dev-cmd/cat" + args = Homebrew.cat_args.parse(["--cask", "cask_name"]) + expect(args.cask?).to be(true) + end end context "with conflicting --formula switch" do