lib/autoproj/cli/update.rb in autoproj-2.14.0 vs lib/autoproj/cli/update.rb in autoproj-2.15.0
- old
+ new
@@ -1,38 +1,34 @@
-require 'autoproj/cli'
-require 'autoproj/cli/base'
-require 'autoproj/cli/status'
-require 'autoproj/ops/import'
+require "autoproj/cli"
+require "autoproj/cli/base"
+require "autoproj/cli/status"
+require "autoproj/ops/import"
module Autoproj
module CLI
class Update < Base
def validate_options(selection, options)
selection, options = super
- if from = options[:from]
+ if (from = options[:from])
options[:from] = Autoproj::InstallationManifest.from_workspace_root(from)
end
- if options[:no_deps_shortcut]
- options[:deps] = false
- end
+ options[:deps] = false if options[:no_deps_shortcut]
if options[:aup] && !options[:config] && !options[:all] && selection.empty?
if Dir.pwd == ws.root_dir
options[:all] = true
else
selection = [Dir.pwd]
end
end
- if options.delete(:force_reset)
- options[:reset] = :force
- end
+ options[:reset] = :force if options.delete(:force_reset)
- if mainline = options[:mainline]
- if mainline == 'mainline' || mainline == 'true'
+ if (mainline = options[:mainline])
+ if mainline == "mainline" || mainline == "true"
options[:mainline] = true
end
end
has_explicit_selection = !selection.empty?
@@ -62,11 +58,11 @@
options[:bundler] = update_autoproj
options[:autoproj] = update_autoproj
options[:config] = update_config
options[:packages] = update_packages
- return selection, options
+ [selection, options]
end
def run(selected_packages, run_hook: false, report: true, ask: false, **options)
ws.manifest.accept_unavailable_osdeps = !options[:osdeps]
ws.setup
@@ -89,31 +85,31 @@
reset: options[:reset],
keep_going: options[:keep_going],
retry_count: options[:retry_count]
)
rescue ImportFailed => configuration_import_failure
- if !options[:keep_going]
- raise
- end
+ raise unless options[:keep_going]
ensure
ws.config.save
end
if options[:packages]
command_line_selection, selected_packages =
finish_loading_configuration(selected_packages)
else
ws.setup_all_package_directories
ws.finalize_package_setup
- command_line_selection, selected_packages = [], PackageSelection.new
+ command_line_selection = []
+ selected_packages = PackageSelection.new
end
osdeps_options = normalize_osdeps_options(
checkout_only: options[:checkout_only],
osdeps_mode: options[:osdeps_mode],
osdeps: options[:osdeps],
- osdeps_filter_uptodate: options[:osdeps_filter_uptodate])
+ osdeps_filter_uptodate: options[:osdeps_filter_uptodate]
+ )
source_packages, osdep_packages, import_failure =
update_packages(
selected_packages,
osdeps: options[:osdeps],
@@ -126,11 +122,12 @@
keep_going: options[:keep_going],
parallel: options[:parallel] || ws.config.parallel_import_level,
retry_count: options[:retry_count],
auto_exclude: options[:auto_exclude],
ask: ask,
- report: report)
+ report: report
+ )
ws.finalize_setup
ws.export_installation_manifest
if options[:osdeps] && !osdep_packages.empty?
@@ -139,16 +136,16 @@
end
if run_hook
if options[:osdeps]
CLI::Main.run_post_command_hook(:update, ws,
- source_packages: source_packages,
- osdep_packages: osdep_packages)
+ source_packages: source_packages,
+ osdep_packages: osdep_packages)
else
CLI::Main.run_post_command_hook(:update, ws,
- source_packages: source_packages,
- osdep_packages: [])
+ source_packages: source_packages,
+ osdep_packages: [])
end
end
export_env_sh
@@ -160,36 +157,37 @@
elsif configuration_import_failure
raise configuration_import_failure
end
end
- return command_line_selection, source_packages, osdep_packages
+ [command_line_selection, source_packages, osdep_packages]
end
def finish_loading_configuration(selected_packages)
ws.setup_all_package_directories
# Call resolve_user_selection once to auto-add packages
resolve_user_selection(selected_packages)
# Now we can finalize and re-resolve the selection since the
# overrides.rb files might have changed it
ws.finalize_package_setup
# Finally, filter out exclusions
- resolved_selected_packages, _ =
+ resolved_selected_packages, =
resolve_user_selection(selected_packages)
validate_user_selection(selected_packages, resolved_selected_packages)
- if !selected_packages.empty?
- command_line_selection = resolved_selected_packages.dup
- else
+ if selected_packages.empty?
command_line_selection = Array.new
+ else
+ command_line_selection = resolved_selected_packages.dup
end
- return command_line_selection, resolved_selected_packages
+ [command_line_selection, resolved_selected_packages]
end
def normalize_osdeps_options(
checkout_only: false, osdeps: true, osdeps_mode: nil,
- osdeps_filter_uptodate: true)
+ osdeps_filter_uptodate: true
+ )
osdeps_options = Hash[install_only: checkout_only]
if osdeps_mode
osdeps_options[:osdeps_mode] = osdeps_mode
elsif !osdeps
@@ -216,11 +214,11 @@
end
clean = !status.unexpected &&
(status.sync || (status.local && !status.remote))
if clean
- msg = Autobuild.color('already up-to-date', :green)
+ msg = Autobuild.color("already up-to-date", :green)
pkg.autobuild.message "#{msg} %s"
return false
end
Autobuild.progress_display_synchronize do
@@ -228,11 +226,11 @@
@prompt.yes?("Update #{pkg.name} ?")
end
end
def lookahead(pkg)
- @futures[pkg] = Concurrent::Future.execute(executor: @executor) do
+ @futures[pkg] = Concurrent::Promises.future_on(@executor) do
Status.status_of_package(
pkg, snapshot: false, only_local: @only_local
)
end
end
@@ -255,13 +253,14 @@
else
->(pkg) { true }
end
ops = Autoproj::Ops::Import.new(
- ws, report_path: (ws.import_report_path if report))
+ ws, report_path: (ws.import_report_path if report)
+ )
source_packages, osdep_packages =
- ops.import_packages(selected_packages,
+ ops.import_packages(selected_packages,
checkout_only: checkout_only,
only_local: only_local,
reset: reset,
recursive: deps,
keep_going: keep_going,
@@ -282,17 +281,16 @@
end
def setup_update_from(other_root)
manifest.each_autobuild_package do |pkg|
if pkg.importer.respond_to?(:pick_from_autoproj_root)
- if !pkg.importer.pick_from_autoproj_root(pkg, other_root)
+ unless pkg.importer.pick_from_autoproj_root(pkg, other_root)
pkg.update = false
end
else
pkg.update = false
end
end
end
end
end
end
-