modifies logic to only compare versions if auto_updates is false

This commit is contained in:
Case Taintor 2024-09-26 13:41:22 +02:00
parent 31c560e578
commit 20444638f3

View File

@ -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