From 2af4254e829c1670189007b9db1f3d95e183164d Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Wed, 7 Jul 2021 17:38:47 +1000 Subject: [PATCH 1/6] unversioned_cask_checker: check for versions in qlplugins --- Library/Homebrew/unversioned_cask_checker.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 462d43990a..fde32b4390 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -31,6 +31,11 @@ module Homebrew @apps ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::App) } end + sig { returns(T::Array[Cask::Artifact::Qlplugin]) } + def qlplugins + @qlplugins ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::Qlplugin) } + end + sig { returns(T::Array[Cask::Artifact::Pkg]) } def pkgs @pkgs ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::Pkg) } @@ -78,8 +83,18 @@ module Homebrew installer.extract_primary_container(to: dir) - info_plist_paths = apps.flat_map do |app| - top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")).sort + info_plist_paths = [] + + apps.flat_map do |app| + top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")) + .sort + .each {|match| info_plist_paths.push(match)} + end + + qlplugins.flat_map do |qlplugin| + top_level_info_plists(Pathname.glob(dir/"**"/qlplugin.source.basename/"Contents"/"Info.plist")) + .sort + .each {|match| info_plist_paths.push(match)} end info_plist_paths.each(&parse_info_plist) From b8a6cbe41093e38d6e38ae51404180a2dc615413 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Wed, 7 Jul 2021 17:40:35 +1000 Subject: [PATCH 2/6] fix style --- Library/Homebrew/unversioned_cask_checker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index fde32b4390..879d71fcab 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -88,13 +88,13 @@ module Homebrew apps.flat_map do |app| top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")) .sort - .each {|match| info_plist_paths.push(match)} + .each { |match| info_plist_paths.push(match) } end qlplugins.flat_map do |qlplugin| top_level_info_plists(Pathname.glob(dir/"**"/qlplugin.source.basename/"Contents"/"Info.plist")) .sort - .each {|match| info_plist_paths.push(match)} + .each { |match| info_plist_paths.push(match) } end info_plist_paths.each(&parse_info_plist) From 24c975f150c0b2c2bc155ccebc56871ea876edb5 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Tue, 13 Jul 2021 20:02:57 +1000 Subject: [PATCH 3/6] Update Library/Homebrew/unversioned_cask_checker.rb Co-authored-by: Maxim Belkin --- Library/Homebrew/unversioned_cask_checker.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 879d71fcab..82a16aeec2 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -83,18 +83,8 @@ module Homebrew installer.extract_primary_container(to: dir) - info_plist_paths = [] - - apps.flat_map do |app| - top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")) - .sort - .each { |match| info_plist_paths.push(match) } - end - - qlplugins.flat_map do |qlplugin| - top_level_info_plists(Pathname.glob(dir/"**"/qlplugin.source.basename/"Contents"/"Info.plist")) - .sort - .each { |match| info_plist_paths.push(match) } + info_plist_paths = (apps + qlplugins).flat_map do |app| + top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")).sort end info_plist_paths.each(&parse_info_plist) From 212992a4764f2486880f2c6f9fbb6122e813ad29 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Wed, 21 Jul 2021 16:09:09 +1000 Subject: [PATCH 4/6] fix typecheck, add reference in bump-unversioned-casks --- Library/Homebrew/dev-cmd/bump-unversioned-casks.rb | 2 +- Library/Homebrew/unversioned_cask_checker.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb index e0c44fad14..c5261809b9 100644 --- a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb +++ b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb @@ -91,7 +91,7 @@ module Homebrew unversioned_cask_checker = UnversionedCaskChecker.new(cask) - if !unversioned_cask_checker.single_app_cask? && !unversioned_cask_checker.single_pkg_cask? + if !unversioned_cask_checker.single_app_cask? && !unversioned_cask_checker.single_pkg_cask? && !unversioned_cask_checker.single_qlplugin_cask? opoo "Skipping, not a single-app or PKG cask." return end diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 82a16aeec2..836d097a1b 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -46,6 +46,11 @@ module Homebrew apps.count == 1 end + sig { returns(T::Boolean) } + def single_qlplugin_cask? + qlplugins.count == 1 + end + sig { returns(T::Boolean) } def single_pkg_cask? pkgs.count == 1 @@ -83,8 +88,8 @@ module Homebrew installer.extract_primary_container(to: dir) - info_plist_paths = (apps + qlplugins).flat_map do |app| - top_level_info_plists(Pathname.glob(dir/"**"/app.source.basename/"Contents"/"Info.plist")).sort + info_plist_paths = (apps.concat(qlplugins)).flat_map do |artifact| + top_level_info_plists(Pathname.glob(dir/"**"/artifact.source.basename/"Contents"/"Info.plist")).sort end info_plist_paths.each(&parse_info_plist) From 5040ec814205dd28055c0c3bf6c0601a5ba929e8 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Wed, 21 Jul 2021 16:25:11 +1000 Subject: [PATCH 5/6] fix style issues --- Library/Homebrew/dev-cmd/bump-unversioned-casks.rb | 4 +++- Library/Homebrew/unversioned_cask_checker.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb index c5261809b9..3caf75982b 100644 --- a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb +++ b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb @@ -91,7 +91,9 @@ module Homebrew unversioned_cask_checker = UnversionedCaskChecker.new(cask) - if !unversioned_cask_checker.single_app_cask? && !unversioned_cask_checker.single_pkg_cask? && !unversioned_cask_checker.single_qlplugin_cask? + if !unversioned_cask_checker.single_app_cask? && + !unversioned_cask_checker.single_pkg_cask? && + !unversioned_cask_checker.single_qlplugin_cask? opoo "Skipping, not a single-app or PKG cask." return end diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 836d097a1b..28aac75e19 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -88,7 +88,7 @@ module Homebrew installer.extract_primary_container(to: dir) - info_plist_paths = (apps.concat(qlplugins)).flat_map do |artifact| + info_plist_paths = apps.concat(qlplugins).flat_map do |artifact| top_level_info_plists(Pathname.glob(dir/"**"/artifact.source.basename/"Contents"/"Info.plist")).sort end From 778d5df6d4bf44b832a4d15ade004227cac1b328 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Thu, 22 Jul 2021 19:36:50 +1000 Subject: [PATCH 6/6] add qlplugins check to guess_cask_version --- Library/Homebrew/unversioned_cask_checker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 28aac75e19..0f68c67a10 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -122,8 +122,8 @@ module Homebrew sig { returns(T.nilable(String)) } def guess_cask_version - if apps.empty? && pkgs.empty? - opoo "Cask #{cask} does not contain any apps or PKG installers." + if apps.empty? && pkgs.empty? && qlplugins.empty? + opoo "Cask #{cask} does not contain any apps, qlplugins or PKG installers." return end