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
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, 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, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
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.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 |
# File 'cmd/upgrade.rb', line 143 def run if args.build_from_source? && args.named.empty? raise ArgumentError, "`--build-from-source` requires at least one formula" end 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)) if args.named.present? 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?) formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled? formulae_prefetched = T.let(false, T::Boolean) prefetched_casks = T.let(false, T::Boolean) shared_download_queue = T.let(nil, T.nilable(Homebrew::DownloadQueue)) if !args.dry_run? && !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?, ) end unless only_upgrade_formulae upgrade_outdated_casks!( casks, skip_prefetch: prefetched_casks, show_upgrade_summary: prefetched_cask_upgrades.blank?, 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 |