From 20444638f33c329f3b7d139b3d0cd026c9062ab1 Mon Sep 17 00:00:00 2001 From: Case Taintor Date: Thu, 26 Sep 2024 13:41:22 +0200 Subject: [PATCH] modifies logic to only compare versions if auto_updates is false --- Library/Homebrew/cask/artifact/moved.rb | 56 ++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index 1a4e1629f8..ee4a040051 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -51,40 +51,40 @@ module Cask if adopt ohai "Adopting existing #{self.class.english_name} at '#{target}'" - source_plist = Pathname("#{source}/Contents/Info.plist") - target_plist = Pathname("#{target}/Contents/Info.plist") - same = if source_plist.size? && - (source_bundle_version = Homebrew::BundleVersion.from_info_plist(source_plist)) && - target_plist.size? && - (target_bundle_version = Homebrew::BundleVersion.from_info_plist(target_plist)) - if source_bundle_version.short_version == target_bundle_version.short_version - if source_bundle_version.version == target_bundle_version.version - true + unless auto_updates + source_plist = Pathname("#{source}/Contents/Info.plist") + target_plist = Pathname("#{target}/Contents/Info.plist") + same = if source_plist.size? && + (source_bundle_version = Homebrew::BundleVersion.from_info_plist(source_plist)) && + target_plist.size? && + (target_bundle_version = Homebrew::BundleVersion.from_info_plist(target_plist)) + if source_bundle_version.short_version == target_bundle_version.short_version + if source_bundle_version.version == target_bundle_version.version + true + else + onoe "The bundle version of #{source} is #{source_bundle_version.version} but " \ + "is #{target_bundle_version.version} for #{target}!" + false + end else - onoe "The bundle version of #{source} is #{source_bundle_version.version} but " \ - "is #{target_bundle_version.version} for #{target}!" + onoe "The bundle short version of #{source} is #{source_bundle_version.short_version} but " \ + "is #{target_bundle_version.short_version} for #{target}!" false end else - onoe "The bundle short version of #{source} is #{source_bundle_version.short_version} but " \ - "is #{target_bundle_version.short_version} for #{target}!" - false + command.run( + "/usr/bin/diff", + args: ["--recursive", "--brief", source, target], + verbose:, + print_stdout: verbose, + ).success? end - else - command.run( - "/usr/bin/diff", - args: ["--recursive", "--brief", source, target], - verbose:, - print_stdout: verbose, - ).success? - end - same = true if auto_updates - - unless same - raise CaskError, - "It seems the existing #{self.class.english_name} is different from " \ - "the one being installed." + unless same + raise CaskError, + "It seems the existing #{self.class.english_name} is different from " \ + "the one being installed." + end end # Remove the source as we don't need to move it to the target location