From 92ef8f5c0d1f5eb3c26be0d92cf058d705aac985 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 3 Nov 2021 14:46:45 -0400 Subject: [PATCH 1/4] `cask/audit`: fix arg handling --- Library/Homebrew/cask/audit.rb | 11 ++++++----- manpages/brew.1 | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 080bc6f109..dc0f94d4b8 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -27,15 +27,16 @@ module Cask new_cask: nil) # `new_cask` implies `online` and `strict` - online = new_cask if online.nil? - strict = new_cask if strict.nil? + online = new_cask if online.blank? + strict = new_cask if strict.blank? # `online` implies `appcast` and `download` - appcast = online if appcast.nil? - download = online if download.nil? + appcast = online if appcast.nil? # `appcast` is `nil` if neither `--appcast` nor `--no-appcast` are passed + download = online if download.blank? + odie online # `new_cask` implies `token_conflicts` - token_conflicts = new_cask if token_conflicts.nil? + token_conflicts = new_cask if token_conflicts.blank? @cask = cask @appcast = appcast diff --git a/manpages/brew.1 b/manpages/brew.1 index 07c060d121..3830731697 100644 --- a/manpages/brew.1 +++ b/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" "October 2021" "Homebrew" "brew" +.TH "BREW" "1" "November 2021" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The Missing Package Manager for macOS (or Linux) From 34204a499b0e7fa63f3dcc2a1a8cc25085c4bfcf Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 3 Nov 2021 21:03:06 -0400 Subject: [PATCH 2/4] Update Library/Homebrew/cask/audit.rb --- Library/Homebrew/cask/audit.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index dc0f94d4b8..d365b5b77b 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -34,7 +34,6 @@ module Cask appcast = online if appcast.nil? # `appcast` is `nil` if neither `--appcast` nor `--no-appcast` are passed download = online if download.blank? - odie online # `new_cask` implies `token_conflicts` token_conflicts = new_cask if token_conflicts.blank? From 46f7c8b0b689f6406a8dfee81746daf515195399 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 6 Nov 2021 00:51:20 -0400 Subject: [PATCH 3/4] Move handling to `dev-cmd/audit.rb` --- Library/Homebrew/cask/audit.rb | 10 +++++----- Library/Homebrew/dev-cmd/audit.rb | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index d365b5b77b..080bc6f109 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -27,15 +27,15 @@ module Cask new_cask: nil) # `new_cask` implies `online` and `strict` - online = new_cask if online.blank? - strict = new_cask if strict.blank? + online = new_cask if online.nil? + strict = new_cask if strict.nil? # `online` implies `appcast` and `download` - appcast = online if appcast.nil? # `appcast` is `nil` if neither `--appcast` nor `--no-appcast` are passed - download = online if download.blank? + appcast = online if appcast.nil? + download = online if download.nil? # `new_cask` implies `token_conflicts` - token_conflicts = new_cask if token_conflicts.blank? + token_conflicts = new_cask if token_conflicts.nil? @cask = cask @appcast = appcast diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f58971355..5ca4cb4f78 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -206,14 +206,17 @@ module Homebrew require "cask/cmd/abstract_command" require "cask/cmd/audit" + # For switches, we add `|| nil` so that `nil` will be passed instead of `false` if they aren't set. + # This way, we can distinguish between "not set" and "set to false". Cask::Cmd::Audit.audit_casks( *audit_casks, download: nil, + # No need for `|| nil` because this is a `--[no-]appcast` and automatically sets itself to `nil` if not passed appcast: args.appcast?, - online: args.online?, - strict: args.strict?, - new_cask: args.new_cask?, - token_conflicts: args.token_conflicts?, + online: args.online? || nil, + strict: args.strict? || nil, + new_cask: args.new_cask? || nil, + token_conflicts: args.token_conflicts? || nil, quarantine: nil, any_named_args: !no_named_args, language: nil, From e09139fb47f774e6920d4de9f42ad277cb69695d Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 6 Nov 2021 00:59:46 -0400 Subject: [PATCH 4/4] Clarify comment --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5ca4cb4f78..d964db2a2b 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -211,7 +211,7 @@ module Homebrew Cask::Cmd::Audit.audit_casks( *audit_casks, download: nil, - # No need for `|| nil` because this is a `--[no-]appcast` and automatically sets itself to `nil` if not passed + # No need for `|| nil` for `--[no-]appcast` because boolean switches are already `nil` if not passed appcast: args.appcast?, online: args.online? || nil, strict: args.strict? || nil,