Class: Homebrew::Cmd::UpgradeCmd Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::UpgradeCmd
- Defined in:
- cmd/upgrade.rb,
sorbet/rbi/dsl/homebrew/cmd/upgrade_cmd.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args, FinalUpgradeSummary, FormulaeUpgradeContext
Instance Method Summary collapse
- #args ⇒ Homebrew::Cmd::UpgradeCmd::Args private
- #initialize(argv = ARGV.freeze) ⇒ void constructor private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
Constructor Details
#initialize(argv = ARGV.freeze) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
157 158 159 160 |
# File 'cmd/upgrade.rb', line 157 def initialize(argv = ARGV.freeze) super @ask_prompt_required = T.let(false, T::Boolean) end |
Instance Method Details
#args ⇒ Homebrew::Cmd::UpgradeCmd::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/cmd/upgrade_cmd.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'cmd/upgrade.rb', line 163 def run if args.build_from_source? && args.named.empty? raise ArgumentError, "`--build-from-source` requires at least one formula" end raise UsageError, "`--minimum-version` requires exactly one formula or cask argument." if minimum_version.present? && args.named.length != 1 formulae = T.let([], T::Array[Formula]) casks = T.let([], T::Array[Cask::Cask]) unavailable_errors = T.let( [], T::Array[T.any(FormulaOrCaskUnavailableError, NoSuchKegError)], ) @prefetched_formulae_upgrade_context = T.let(nil, T.nilable(FormulaeUpgradeContext)) prefetched_formulae_names = T.let([], T::Array[String]) prefetched_formulae_upgrades = T.let([], T::Array[String]) prefetched_cask_names = T.let([], T::Array[String]) prefetched_cask_upgrades = T.let([], T::Array[String]) @final_upgrade_summary = T.let(FinalUpgradeSummary.new, T.nilable(FinalUpgradeSummary)) @ask_prompt_required = false if args.named.present? Homebrew::Trust.trust_fully_qualified_items!(args.named, type: args.only_formula_or_cask) args.named.to_formulae_and_casks_and_unavailable(method: :resolve).each do |item| case item when FormulaOrCaskUnavailableError, NoSuchKegError unavailable_errors << item when Formula formulae << item when Cask::Cask casks << item end end end # If one or more formulae are specified, but no casks were # specified, we want to make note of that so we don't # try to upgrade all outdated casks. # # When names were given, we must also prevent empty resolved lists # from triggering the "upgrade all" path (which happens when all # names failed resolution). named_given = args.named.present? only_upgrade_formulae = (named_given && casks.blank?) || (formulae.present? && casks.blank?) only_upgrade_casks = (named_given && formulae.blank?) || (casks.present? && formulae.blank?) if Homebrew::EnvConfig.verify_attestations? formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) end formulae_prefetched = T.let(false, T::Boolean) prefetched_casks = T.let(false, T::Boolean) ask_upgrade_planned = T.let(false, T::Boolean) shared_download_queue = T.let(nil, T.nilable(Homebrew::DownloadQueue)) if args.ask? unless only_upgrade_casks upgrade_outdated_formulae!( formulae, dry_run: true, show_upgrade_summary: false, ) end unless only_upgrade_formulae upgrade_outdated_casks!( casks, dry_run: true, skip_prefetch: false, show_upgrade_summary: false, download_queue: nil, ) end show_final_upgrade_summary(dry_run: true) if Install.ask_prompt_needed?( planned_names: final_upgrade_summary.version_changes.map do |version_change| planned_name = version_change.split.fetch(0) formulae.find { |formula| formula.full_specified_name == planned_name }&.full_name || planned_name end, requested_names: args.named, force: @ask_prompt_required, named: args.named.present?, ) Install.ask(action: "upgrade") end ask_upgrade_planned = final_upgrade_summary.version_changes.present? @final_upgrade_summary = FinalUpgradeSummary.new end if !args.dry_run? && (!args.ask? || ask_upgrade_planned) && !only_upgrade_formulae && !only_upgrade_casks shared_download_queue = Homebrew::DownloadQueue.new(pour: true) begin formulae_prefetched = upgrade_outdated_formulae!( formulae, prefetch_only: true, download_queue: shared_download_queue, prefetch_names: prefetched_formulae_names, prefetch_upgrades: prefetched_formulae_upgrades, show_upgrade_summary: false, show_downloads_heading: false, ) prefetched_casks = prefetch_outdated_casks!( casks, download_queue: shared_download_queue, prefetch_names: prefetched_cask_names, prefetch_upgrades: prefetched_cask_upgrades, show_downloads_heading: false, ) Cask::Upgrade.show_upgrade_summary( prefetched_formulae_upgrades + prefetched_cask_upgrades, dry_run: args.dry_run?, ) Install.show_combined_fetch_downloads_heading( formula_names: prefetched_formulae_names, cask_names: prefetched_cask_names, ) shared_download_queue.fetch if shared_download_queue.fetch_failed formulae_prefetched = false prefetched_casks = false end ensure shared_download_queue.shutdown end end unless only_upgrade_casks upgrade_outdated_formulae!( formulae, use_prefetched: formulae_prefetched, show_upgrade_summary: prefetched_formulae_upgrades.blank? && !args.dry_run? && !args.ask?, ) end unless only_upgrade_formulae upgrade_outdated_casks!( casks, skip_prefetch: prefetched_casks, show_upgrade_summary: prefetched_cask_upgrades.blank? && !args.dry_run? && !args.ask?, download_queue: nil, ) end unavailable_errors.each { |e| ofail e } Cleanup.periodic_clean!(dry_run: args.dry_run?) Homebrew::Reinstall.reinstall_pkgconf_if_needed!(dry_run: args.dry_run?) Homebrew..(display_times: args.display_times?) show_final_upgrade_summary end |