Skip to content

Commit db32c04

Browse files
committed
cask: show accurate log messages for in-place upgrades
1 parent 6e01bb1 commit db32c04

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Library/Homebrew/cask/artifact/moved.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,10 @@ def move(adopt: false, auto_updates: false, force: false, verbose: false, predec
102102
end
103103
end
104104

105-
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
106-
107105
Utils.gain_permissions_mkpath(target.dirname, command:) unless target.dirname.exist?
108106

109107
if target.directory? && Quarantine.app_management_permissions_granted?(app: target, command:)
108+
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}' in-place"
110109
if target.writable?
111110
source.children.each { |child| FileUtils.move(child, target/child.basename) }
112111
else
@@ -116,8 +115,10 @@ def move(adopt: false, auto_updates: false, force: false, verbose: false, predec
116115
Quarantine.copy_xattrs(source, target, command:)
117116
FileUtils.rm_r(source)
118117
elsif target.dirname.writable?
118+
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
119119
FileUtils.move(source, target)
120120
else
121+
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
121122
# default sudo user isn't necessarily able to write to Homebrew's locations
122123
# e.g. with runas_default set in the sudoers (5) file.
123124
command.run!("/bin/cp", args: ["-pR", source, target], sudo: true)
@@ -179,20 +180,21 @@ def move_back(skip: false, force: false, adopt: false, command: nil, **options)
179180
end
180181

181182
def delete(target, force: false, successor: nil, command: nil, **_)
182-
ohai "Removing #{self.class.english_name} '#{target}'"
183183
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if undeletable?(target)
184184

185185
return unless Utils.path_occupied?(target)
186186

187187
if target.directory? && matching_artifact?(successor) && Quarantine.app_management_permissions_granted?(
188188
app: target, command:,
189189
)
190+
ohai "Upgrading #{self.class.english_name} '#{target}' in-place"
190191
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
191192
# Remove only the contents to handle this case.
192193
target.children.each do |child|
193194
Utils.gain_permissions_remove(child, command:)
194195
end
195196
else
197+
ohai "Removing #{self.class.english_name} '#{target}'"
196198
Utils.gain_permissions_remove(target, command:)
197199
end
198200
end

0 commit comments

Comments
 (0)