autoproj 2.12.1 → 2.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +24 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +6 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +225 -200
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +224 -199
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +9 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +66 -36
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/python.rb +18 -0
  25. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  26. data/lib/autoproj/base.rb +1 -1
  27. data/lib/autoproj/bash_completion.rb +5 -6
  28. data/lib/autoproj/build_option.rb +22 -24
  29. data/lib/autoproj/cli/base.rb +26 -26
  30. data/lib/autoproj/cli/bootstrap.rb +14 -16
  31. data/lib/autoproj/cli/build.rb +10 -7
  32. data/lib/autoproj/cli/cache.rb +11 -11
  33. data/lib/autoproj/cli/clean.rb +10 -10
  34. data/lib/autoproj/cli/commit.rb +7 -8
  35. data/lib/autoproj/cli/doc.rb +2 -2
  36. data/lib/autoproj/cli/envsh.rb +1 -2
  37. data/lib/autoproj/cli/exec.rb +60 -20
  38. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  39. data/lib/autoproj/cli/locate.rb +30 -41
  40. data/lib/autoproj/cli/log.rb +7 -7
  41. data/lib/autoproj/cli/main.rb +217 -205
  42. data/lib/autoproj/cli/main_doc.rb +22 -21
  43. data/lib/autoproj/cli/main_global.rb +44 -19
  44. data/lib/autoproj/cli/main_plugin.rb +18 -18
  45. data/lib/autoproj/cli/main_test.rb +28 -27
  46. data/lib/autoproj/cli/manifest.rb +7 -7
  47. data/lib/autoproj/cli/osdeps.rb +12 -11
  48. data/lib/autoproj/cli/patcher.rb +2 -3
  49. data/lib/autoproj/cli/query.rb +17 -18
  50. data/lib/autoproj/cli/reconfigure.rb +1 -2
  51. data/lib/autoproj/cli/reset.rb +9 -12
  52. data/lib/autoproj/cli/show.rb +38 -39
  53. data/lib/autoproj/cli/status.rb +56 -44
  54. data/lib/autoproj/cli/switch_config.rb +5 -6
  55. data/lib/autoproj/cli/tag.rb +12 -11
  56. data/lib/autoproj/cli/test.rb +7 -7
  57. data/lib/autoproj/cli/update.rb +97 -43
  58. data/lib/autoproj/cli/utility.rb +14 -12
  59. data/lib/autoproj/cli/version.rb +42 -40
  60. data/lib/autoproj/cli/versions.rb +14 -15
  61. data/lib/autoproj/cli/watch.rb +33 -37
  62. data/lib/autoproj/cli/which.rb +16 -20
  63. data/lib/autoproj/cli.rb +4 -2
  64. data/lib/autoproj/configuration.rb +78 -86
  65. data/lib/autoproj/default.osdeps +29 -3
  66. data/lib/autoproj/environment.rb +42 -23
  67. data/lib/autoproj/exceptions.rb +9 -3
  68. data/lib/autoproj/find_workspace.rb +20 -25
  69. data/lib/autoproj/git_server_configuration.rb +40 -44
  70. data/lib/autoproj/gitorious.rb +1 -1
  71. data/lib/autoproj/installation_manifest.rb +64 -29
  72. data/lib/autoproj/local_package_set.rb +13 -11
  73. data/lib/autoproj/manifest.rb +139 -132
  74. data/lib/autoproj/metapackage.rb +2 -6
  75. data/lib/autoproj/ops/atomic_write.rb +7 -6
  76. data/lib/autoproj/ops/build.rb +4 -6
  77. data/lib/autoproj/ops/cache.rb +41 -43
  78. data/lib/autoproj/ops/cached_env.rb +5 -4
  79. data/lib/autoproj/ops/configuration.rb +519 -507
  80. data/lib/autoproj/ops/import.rb +88 -63
  81. data/lib/autoproj/ops/install.rb +218 -192
  82. data/lib/autoproj/ops/loader.rb +77 -76
  83. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  84. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  85. data/lib/autoproj/ops/snapshot.rb +250 -247
  86. data/lib/autoproj/ops/tools.rb +76 -78
  87. data/lib/autoproj/ops/watch.rb +6 -6
  88. data/lib/autoproj/ops/which.rb +17 -14
  89. data/lib/autoproj/options.rb +13 -2
  90. data/lib/autoproj/os_package_installer.rb +102 -92
  91. data/lib/autoproj/os_package_query.rb +7 -13
  92. data/lib/autoproj/os_package_resolver.rb +189 -140
  93. data/lib/autoproj/os_repository_installer.rb +4 -4
  94. data/lib/autoproj/os_repository_resolver.rb +8 -6
  95. data/lib/autoproj/package_definition.rb +12 -13
  96. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
  97. data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
  98. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  99. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  100. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  101. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  102. data/lib/autoproj/package_managers/manager.rb +8 -3
  103. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  104. data/lib/autoproj/package_managers/pip_manager.rb +30 -28
  105. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  106. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  107. data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
  108. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  109. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  110. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  111. data/lib/autoproj/package_manifest.rb +28 -74
  112. data/lib/autoproj/package_selection.rb +187 -187
  113. data/lib/autoproj/package_set.rb +145 -114
  114. data/lib/autoproj/python.rb +297 -0
  115. data/lib/autoproj/query_base.rb +20 -14
  116. data/lib/autoproj/reporter.rb +19 -19
  117. data/lib/autoproj/repository_managers/apt.rb +102 -68
  118. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  119. data/lib/autoproj/ros_condition_parser.rb +84 -0
  120. data/lib/autoproj/ros_package_manifest.rb +125 -0
  121. data/lib/autoproj/shell_completion.rb +16 -13
  122. data/lib/autoproj/source_package_query.rb +29 -36
  123. data/lib/autoproj/system.rb +32 -21
  124. data/lib/autoproj/test.rb +131 -106
  125. data/lib/autoproj/variable_expansion.rb +10 -10
  126. data/lib/autoproj/vcs_definition.rb +53 -37
  127. data/lib/autoproj/version.rb +1 -1
  128. data/lib/autoproj/workspace.rb +143 -108
  129. data/lib/autoproj/zsh_completion.rb +8 -9
  130. data/lib/autoproj.rb +55 -53
  131. data/samples/autoproj/init.rb +1 -2
  132. metadata +86 -65
  133. data/.travis.yml +0 -22
@@ -1,6 +1,7 @@
1
- require 'autoproj/cli'
2
- require 'autoproj/cli/base'
3
- require 'autoproj/ops/import'
1
+ require "autoproj/cli"
2
+ require "autoproj/cli/base"
3
+ require "autoproj/cli/status"
4
+ require "autoproj/ops/import"
4
5
 
5
6
  module Autoproj
6
7
  module CLI
@@ -8,13 +9,11 @@ module Autoproj
8
9
  def validate_options(selection, options)
9
10
  selection, options = super
10
11
 
11
- if from = options[:from]
12
+ if (from = options[:from])
12
13
  options[:from] = Autoproj::InstallationManifest.from_workspace_root(from)
13
14
  end
14
15
 
15
- if options[:no_deps_shortcut]
16
- options[:deps] = false
17
- end
16
+ options[:deps] = false if options[:no_deps_shortcut]
18
17
 
19
18
  if options[:aup] && !options[:config] && !options[:all] && selection.empty?
20
19
  if Dir.pwd == ws.root_dir
@@ -24,12 +23,10 @@ module Autoproj
24
23
  end
25
24
  end
26
25
 
27
- if options.delete(:force_reset)
28
- options[:reset] = :force
29
- end
26
+ options[:reset] = :force if options.delete(:force_reset)
30
27
 
31
- if mainline = options[:mainline]
32
- if mainline == 'mainline' || mainline == 'true'
28
+ if (mainline = options[:mainline])
29
+ if mainline == "mainline" || mainline == "true"
33
30
  options[:mainline] = true
34
31
  end
35
32
  end
@@ -63,20 +60,23 @@ module Autoproj
63
60
  options[:autoproj] = update_autoproj
64
61
  options[:config] = update_config
65
62
  options[:packages] = update_packages
66
- return selection, options
63
+ [selection, options]
67
64
  end
68
65
 
69
- def run(selected_packages, run_hook: false, report: true, **options)
66
+ def run(selected_packages, run_hook: false, report: true, ask: false, **options)
70
67
  ws.manifest.accept_unavailable_osdeps = !options[:osdeps]
71
68
  ws.setup
72
69
  ws.autodetect_operating_system(force: true)
73
- if options[:bundler]
74
- ws.update_bundler
75
- end
76
- if options[:autoproj]
77
- ws.update_autoproj
70
+
71
+ if ask
72
+ prompt = TTY::Prompt.new
73
+ options[:bundler] &&= prompt.yes?("Update bundler ?")
74
+ options[:autoproj] &&= prompt.yes?("Update autoproj ?")
78
75
  end
79
76
 
77
+ ws.update_bundler if options[:bundler]
78
+ ws.update_autoproj if options[:autoproj]
79
+
80
80
  begin
81
81
  ws.load_package_sets(
82
82
  mainline: options[:mainline],
@@ -84,11 +84,10 @@ module Autoproj
84
84
  checkout_only: !options[:config] || options[:checkout_only],
85
85
  reset: options[:reset],
86
86
  keep_going: options[:keep_going],
87
- retry_count: options[:retry_count])
87
+ retry_count: options[:retry_count]
88
+ )
88
89
  rescue ImportFailed => configuration_import_failure
89
- if !options[:keep_going]
90
- raise
91
- end
90
+ raise unless options[:keep_going]
92
91
  ensure
93
92
  ws.config.save
94
93
  end
@@ -99,14 +98,16 @@ module Autoproj
99
98
  else
100
99
  ws.setup_all_package_directories
101
100
  ws.finalize_package_setup
102
- command_line_selection, selected_packages = [], PackageSelection.new
101
+ command_line_selection = []
102
+ selected_packages = PackageSelection.new
103
103
  end
104
104
 
105
105
  osdeps_options = normalize_osdeps_options(
106
106
  checkout_only: options[:checkout_only],
107
107
  osdeps_mode: options[:osdeps_mode],
108
108
  osdeps: options[:osdeps],
109
- osdeps_filter_uptodate: options[:osdeps_filter_uptodate])
109
+ osdeps_filter_uptodate: options[:osdeps_filter_uptodate]
110
+ )
110
111
 
111
112
  source_packages, osdep_packages, import_failure =
112
113
  update_packages(
@@ -122,7 +123,9 @@ module Autoproj
122
123
  parallel: options[:parallel] || ws.config.parallel_import_level,
123
124
  retry_count: options[:retry_count],
124
125
  auto_exclude: options[:auto_exclude],
125
- report: report)
126
+ ask: ask,
127
+ report: report
128
+ )
126
129
 
127
130
  ws.finalize_setup
128
131
  ws.export_installation_manifest
@@ -135,12 +138,12 @@ module Autoproj
135
138
  if run_hook
136
139
  if options[:osdeps]
137
140
  CLI::Main.run_post_command_hook(:update, ws,
138
- source_packages: source_packages,
139
- osdep_packages: osdep_packages)
141
+ source_packages: source_packages,
142
+ osdep_packages: osdep_packages)
140
143
  else
141
144
  CLI::Main.run_post_command_hook(:update, ws,
142
- source_packages: source_packages,
143
- osdep_packages: [])
145
+ source_packages: source_packages,
146
+ osdep_packages: [])
144
147
  end
145
148
  end
146
149
 
@@ -156,7 +159,7 @@ module Autoproj
156
159
  end
157
160
  end
158
161
 
159
- return command_line_selection, source_packages, osdep_packages
162
+ [command_line_selection, source_packages, osdep_packages]
160
163
  end
161
164
 
162
165
  def finish_loading_configuration(selected_packages)
@@ -167,21 +170,22 @@ module Autoproj
167
170
  # overrides.rb files might have changed it
168
171
  ws.finalize_package_setup
169
172
  # Finally, filter out exclusions
170
- resolved_selected_packages, _ =
173
+ resolved_selected_packages, =
171
174
  resolve_user_selection(selected_packages)
172
175
  validate_user_selection(selected_packages, resolved_selected_packages)
173
176
 
174
- if !selected_packages.empty?
175
- command_line_selection = resolved_selected_packages.dup
176
- else
177
+ if selected_packages.empty?
177
178
  command_line_selection = Array.new
179
+ else
180
+ command_line_selection = resolved_selected_packages.dup
178
181
  end
179
- return command_line_selection, resolved_selected_packages
182
+ [command_line_selection, resolved_selected_packages]
180
183
  end
181
184
 
182
185
  def normalize_osdeps_options(
183
186
  checkout_only: false, osdeps: true, osdeps_mode: nil,
184
- osdeps_filter_uptodate: true)
187
+ osdeps_filter_uptodate: true
188
+ )
185
189
 
186
190
  osdeps_options = Hash[install_only: checkout_only]
187
191
  if osdeps_mode
@@ -193,18 +197,68 @@ module Autoproj
193
197
  osdeps_options
194
198
  end
195
199
 
200
+ class AskUpdateFilter
201
+ def initialize(prompt, parallel: 1, only_local: false)
202
+ @prompt = prompt
203
+ @only_local = only_local
204
+ @executor = Concurrent::FixedThreadPool.new(parallel, max_length: 0)
205
+
206
+ @parallel = parallel
207
+ @futures = {}
208
+ @lookahead_queue = []
209
+ end
210
+
211
+ def call(pkg)
212
+ unless (status = @futures.delete(pkg).value)
213
+ raise v.reason
214
+ end
215
+
216
+ clean = !status.unexpected &&
217
+ (status.sync || (status.local && !status.remote))
218
+ if clean
219
+ msg = Autobuild.color("already up-to-date", :green)
220
+ pkg.autobuild.message "#{msg} %s"
221
+ return false
222
+ end
223
+
224
+ Autobuild.progress_display_synchronize do
225
+ status.msg.each { |m| puts m }
226
+ @prompt.yes?("Update #{pkg.name} ?")
227
+ end
228
+ end
229
+
230
+ def lookahead(pkg)
231
+ @futures[pkg] = Concurrent::Promises.future_on(@executor) do
232
+ Status.status_of_package(
233
+ pkg, snapshot: false, only_local: @only_local
234
+ )
235
+ end
236
+ end
237
+ end
238
+
196
239
  def update_packages(selected_packages,
197
240
  from: nil, checkout_only: false, only_local: false, reset: false,
198
241
  deps: true, keep_going: false, parallel: 1,
199
242
  retry_count: 0, osdeps: true, auto_exclude: false, osdeps_options: Hash.new,
200
- report: true)
243
+ report: true, ask: false)
201
244
 
202
245
  setup_update_from(from) if from
203
246
 
247
+ filter =
248
+ if ask
249
+ prompt = TTY::Prompt.new
250
+ filter = AskUpdateFilter.new(
251
+ prompt, parallel: parallel, only_local: only_local
252
+ )
253
+ else
254
+ ->(pkg) { true }
255
+ end
256
+
204
257
  ops = Autoproj::Ops::Import.new(
205
- ws, report_path: (ws.import_report_path if report))
258
+ ws, report_path: (ws.import_report_path if report)
259
+ )
206
260
  source_packages, osdep_packages =
207
- ops.import_packages(selected_packages,
261
+ ops.import_packages(selected_packages,
208
262
  checkout_only: checkout_only,
209
263
  only_local: only_local,
210
264
  reset: reset,
@@ -213,7 +267,8 @@ module Autoproj
213
267
  parallel: parallel,
214
268
  retry_count: retry_count,
215
269
  install_vcs_packages: (osdeps_options if osdeps),
216
- auto_exclude: auto_exclude)
270
+ auto_exclude: auto_exclude,
271
+ filter: filter)
217
272
  [source_packages, osdep_packages, nil]
218
273
  rescue ExcludedSelection => e
219
274
  raise CLIInvalidSelection, e.message, e.backtrace
@@ -228,7 +283,7 @@ module Autoproj
228
283
  def setup_update_from(other_root)
229
284
  manifest.each_autobuild_package do |pkg|
230
285
  if pkg.importer.respond_to?(:pick_from_autoproj_root)
231
- if !pkg.importer.pick_from_autoproj_root(pkg, other_root)
286
+ unless pkg.importer.pick_from_autoproj_root(pkg, other_root)
232
287
  pkg.update = false
233
288
  end
234
289
  else
@@ -239,4 +294,3 @@ module Autoproj
239
294
  end
240
295
  end
241
296
  end
242
-
@@ -1,4 +1,4 @@
1
- require 'autoproj/cli/inspection_tool'
1
+ require "autoproj/cli/inspection_tool"
2
2
 
3
3
  module Autoproj
4
4
  module CLI
@@ -10,6 +10,7 @@ module Autoproj
10
10
  end
11
11
 
12
12
  attr_reader :utility_name
13
+
13
14
  def default(enabled)
14
15
  ws.load_config
15
16
  ws.config.utility_default(utility_name, enabled)
@@ -68,9 +69,9 @@ module Autoproj
68
69
  lines = lines.sort_by { |name, _| name }
69
70
  w = lines.map { |name, _| name.length }.max
70
71
  out_format = "%-#{w}s %-7s %-9s"
71
- puts format(out_format, 'Package Name', 'Enabled', 'Available')
72
+ puts format(out_format, "Package Name", "Enabled", "Available")
72
73
  lines.each do |name, enabled, available|
73
- puts(format(out_format, name, (!!enabled).to_s, (!!available).to_s))
74
+ puts(format(out_format, name, (!!enabled).to_s, (!!available).to_s)) # rubocop:disable Style/DoubleNegation
74
75
  end
75
76
  end
76
77
 
@@ -87,7 +88,7 @@ module Autoproj
87
88
  validate_user_selection(user_selection, resolved_selection)
88
89
  if package_names.empty?
89
90
  raise CLIInvalidArguments, "autoproj: the provided package "\
90
- "is not selected for build"
91
+ "is not selected for build"
91
92
  end
92
93
  return if package_names.empty?
93
94
 
@@ -113,22 +114,23 @@ module Autoproj
113
114
  ) do |pkg, phase|
114
115
  reporting&.report_incremental(pkg) if phase == utility_name
115
116
  end
116
-
117
117
  ensure
118
118
  reporting&.create_report(packages.map(&:autobuild))
119
119
  end
120
120
 
121
121
  def package_metadata(autobuild_package)
122
+ # rubocop:disable Style/DoubleNegation
122
123
  u = autobuild_package.utility(@utility_name)
123
124
  {
124
- 'source_dir' => u.source_dir,
125
- 'target_dir' => u.target_dir,
126
- 'available' => !!u.available?,
127
- 'enabled' => !!u.enabled?,
128
- 'invoked' => !!u.invoked?,
129
- 'success' => !!u.success?,
130
- 'installed' => !!u.installed?,
125
+ "source_dir" => u.source_dir,
126
+ "target_dir" => u.target_dir,
127
+ "available" => !!u.available?,
128
+ "enabled" => !!u.enabled?,
129
+ "invoked" => !!u.invoked?,
130
+ "success" => !!u.success?,
131
+ "installed" => !!u.installed?
131
132
  }
133
+ # rubocop:enable Style/DoubleNegation
132
134
  end
133
135
  end
134
136
  end
@@ -1,52 +1,54 @@
1
- require 'autoproj/cli/base'
2
- require 'rubygems'
1
+ require "autoproj/cli/base"
2
+ require "rubygems"
3
3
 
4
4
  module Autoproj
5
- module CLI
6
- class Version < Base
7
- # List the version of autoproj and optionally include
8
- # the installed dependencies with information about the requirement
9
- # and the actual used version
10
- def run(args, options = Hash.new)
11
- puts "autoproj version: #{Autoproj::VERSION}"
12
- return unless options[:deps]
5
+ module CLI
6
+ class Version < Base
7
+ # List the version of autoproj and optionally include
8
+ # the installed dependencies with information about the requirement
9
+ # and the actual used version
10
+ def run(args, options = Hash.new)
11
+ puts "autoproj version: #{Autoproj::VERSION}"
12
+ return unless options[:deps]
13
13
 
14
- dependency = Gem::Deprecate.skip_during do
15
- Gem::Dependency.new "autoproj", Autoproj::VERSION
16
- end
17
- autoproj_spec = dependency.matching_specs
18
- return if autoproj_spec.empty?
14
+ dependency = Gem::Deprecate.skip_during do
15
+ Gem::Dependency.new "autoproj", Autoproj::VERSION
16
+ end
17
+ autoproj_spec = dependency.matching_specs
18
+ return if autoproj_spec.empty?
19
19
 
20
- installed_deps = collect_dependencies(dependency)
21
- puts " specified dependencies:"
22
- autoproj_spec.first.dependencies.each do |dep|
23
- puts " #{dep}: #{installed_deps[dep.name] || 'n/a'}"
24
- installed_deps.delete(dep.name)
25
- end
26
- puts " implicit dependencies:"
27
- installed_deps.keys.sort.each do |name|
28
- puts " #{name}: #{installed_deps[name]}" unless name == "autoproj"
20
+ installed_deps = collect_dependencies(dependency)
21
+ puts " specified dependencies:"
22
+ autoproj_spec.first.dependencies.each do |dep|
23
+ puts " #{dep}: #{installed_deps[dep.name] || 'n/a'}"
24
+ installed_deps.delete(dep.name)
25
+ end
26
+ puts " implicit dependencies:"
27
+ installed_deps.keys.sort.each do |name|
28
+ unless name == "autoproj"
29
+ puts " #{name}: #{installed_deps[name]}"
30
+ end
31
+ end
29
32
  end
30
- end
31
33
 
32
- # Collect the dependencies of a given dependency
33
- # @param [Gem::Dependency] dependency a gem depencency
34
- # @param [Array<Gem::Dependency] list of already known dependencies
35
- #
36
- # @return [Array<Gem::Dependency>] all known dependencies
37
- def collect_dependencies(dependency, known_dependencies: {})
38
- dep_spec = dependency.matching_specs
39
- return known_dependencies if dep_spec.empty?
34
+ # Collect the dependencies of a given dependency
35
+ # @param [Gem::Dependency] dependency a gem depencency
36
+ # @param [Array<Gem::Dependency] list of already known dependencies
37
+ #
38
+ # @return [Array<Gem::Dependency>] all known dependencies
39
+ def collect_dependencies(dependency, known_dependencies: {})
40
+ dep_spec = dependency.matching_specs
41
+ return known_dependencies if dep_spec.empty?
40
42
 
41
- dep_spec = dep_spec.first
42
- known_dependencies[dep_spec.name] = dep_spec.version
43
- dep_spec.dependencies.each do |dep|
44
- if !known_dependencies.has_key?(dep.name)
45
- collect_dependencies(dep, known_dependencies: known_dependencies)
43
+ dep_spec = dep_spec.first
44
+ known_dependencies[dep_spec.name] = dep_spec.version
45
+ dep_spec.dependencies.each do |dep|
46
+ unless known_dependencies.has_key?(dep.name)
47
+ collect_dependencies(dep, known_dependencies: known_dependencies)
48
+ end
46
49
  end
50
+ known_dependencies
47
51
  end
48
- known_dependencies
49
52
  end
50
53
  end
51
54
  end
52
- end
@@ -1,7 +1,7 @@
1
- require 'autoproj'
2
- require 'autoproj/cli/inspection_tool'
3
- require 'autoproj/ops/tools'
4
- require 'autoproj/ops/snapshot'
1
+ require "autoproj"
2
+ require "autoproj/cli/inspection_tool"
3
+ require "autoproj/ops/tools"
4
+ require "autoproj/ops/snapshot"
5
5
 
6
6
  module Autoproj
7
7
  module CLI
@@ -9,22 +9,22 @@ module Autoproj
9
9
  DEFAULT_VERSIONS_FILE_BASENAME = Ops::Snapshot::DEFAULT_VERSIONS_FILE_BASENAME
10
10
 
11
11
  def default_versions_file
12
- File.join( ws.overrides_dir, DEFAULT_VERSIONS_FILE_BASENAME )
12
+ File.join(ws.overrides_dir, DEFAULT_VERSIONS_FILE_BASENAME)
13
13
  end
14
14
 
15
15
  def validate_options(packages, options = Hash.new)
16
16
  packages, options = super
17
- if !options[:save].nil?
17
+ unless options[:save].nil?
18
18
  options[:save] = case options[:save]
19
- when '.'
19
+ when "."
20
20
  nil
21
- when 'save'
21
+ when "save"
22
22
  default_versions_file
23
23
  else
24
24
  options[:save].to_str
25
25
  end
26
26
  end
27
- return packages, options
27
+ [packages, options]
28
28
  end
29
29
 
30
30
  def run(user_selection, options)
@@ -51,13 +51,13 @@ module Autoproj
51
51
  versions += ops.snapshot_package_sets(nil, only_local: options[:only_local])
52
52
  end
53
53
  if snapshot_packages
54
- versions += ops.snapshot_packages(packages,
55
- nil,
56
- only_local: options[:only_local],
57
- fingerprint: options[:fingerprint])
54
+ versions += ops.snapshot_packages(packages,
55
+ nil,
56
+ only_local: options[:only_local],
57
+ fingerprint: options[:fingerprint])
58
58
  end
59
59
 
60
- if output_file = options[:save]
60
+ if (output_file = options[:save])
61
61
  ops.save_versions(versions, output_file, replace: options[:replace])
62
62
  else
63
63
  versions = ops.sort_versions(versions)
@@ -67,4 +67,3 @@ module Autoproj
67
67
  end
68
68
  end
69
69
  end
70
-
@@ -1,6 +1,6 @@
1
- require 'rbconfig'
2
- require 'autoproj/cli/inspection_tool'
3
- require 'autoproj/ops/watch'
1
+ require "rbconfig"
2
+ require "autoproj/cli/inspection_tool"
3
+ require "autoproj/ops/watch"
4
4
  module Autoproj
5
5
  module CLI
6
6
  class Watch < InspectionTool
@@ -13,7 +13,7 @@ module Autoproj
13
13
 
14
14
  def validate_options(unused, options = {})
15
15
  _, options = super(unused, options)
16
- @show_events = options[:show_events]
16
+ @show_events = options[:show_events]
17
17
  nil
18
18
  end
19
19
 
@@ -24,13 +24,11 @@ module Autoproj
24
24
  def update_workspace
25
25
  initialize_and_load
26
26
 
27
- source_packages, _ = finalize_setup([])
27
+ source_packages, = finalize_setup([])
28
28
  @source_packages_dirs = source_packages.map do |pkg_name|
29
29
  ws.manifest.find_autobuild_package(pkg_name).srcdir
30
30
  end
31
- @pkg_sets_dirs = ws.manifest.each_package_set.map do |pkg_set|
32
- pkg_set.raw_local_dir
33
- end
31
+ @pkg_sets_dirs = ws.manifest.each_package_set.map(&:raw_local_dir)
34
32
  export_env_sh(shell_helpers: ws.config.shell_helpers?)
35
33
  end
36
34
 
@@ -44,10 +42,10 @@ module Autoproj
44
42
  @source_packages_dirs = []
45
43
  @package_sets = []
46
44
 
47
- @source_packages_dirs = installation_manifest.each_package.
48
- map(&:srcdir)
49
- @package_sets = installation_manifest.each_package_set.
50
- map(&:raw_local_dir)
45
+ @source_packages_dirs = installation_manifest.each_package
46
+ .map(&:srcdir)
47
+ @package_sets = installation_manifest.each_package_set
48
+ .map(&:raw_local_dir)
51
49
  end
52
50
 
53
51
  def callback
@@ -66,11 +64,10 @@ module Autoproj
66
64
  notifier.watch(dir, :move, :create, :delete, :modify, :dont_follow, *inotify_flags) do |e|
67
65
  file_name = e.absolute_name[strip_dir_range]
68
66
  included = included_paths.empty? ||
69
- included_paths.any? { |rx| rx === file_name }
70
- if included
71
- included = !excluded_paths.any? { |rx| rx === file_name }
72
- end
73
- next if !included
67
+ included_paths.any? { |rx| rx === file_name }
68
+ included = !excluded_paths.any? { |rx| rx === file_name } if included
69
+ next unless included
70
+
74
71
  Autobuild.message "#{e.absolute_name} changed" if show_events?
75
72
  callback
76
73
  end
@@ -79,12 +76,15 @@ module Autoproj
79
76
  def create_src_pkg_watchers
80
77
  @source_packages_dirs.each do |pkg_srcdir|
81
78
  next unless File.exist? pkg_srcdir
79
+
82
80
  create_dir_watcher(pkg_srcdir, included_paths: ["manifest.xml", "package.xml"])
83
81
 
84
- manifest_file = File.join(pkg_srcdir, 'manifest.xml')
82
+ manifest_file = File.join(pkg_srcdir, "manifest.xml")
85
83
  create_file_watcher(manifest_file) if File.exist? manifest_file
86
- ros_manifest_file = File.join(pkg_srcdir, 'package.xml')
87
- create_file_watcher(ros_manifest_file) if File.exist? ros_manifest_file
84
+ ros_manifest_file = File.join(pkg_srcdir, "package.xml")
85
+ if File.exist? ros_manifest_file
86
+ create_file_watcher(ros_manifest_file)
87
+ end
88
88
  end
89
89
  end
90
90
 
@@ -92,12 +92,12 @@ module Autoproj
92
92
  create_file_watcher(ws.config.path)
93
93
  create_src_pkg_watchers
94
94
  create_dir_watcher(ws.config_dir,
95
- excluded_paths: [/(^|#{File::SEPARATOR})\./],
96
- inotify_flags: [:recursive])
95
+ excluded_paths: [/(^|#{File::SEPARATOR})\./],
96
+ inotify_flags: [:recursive])
97
97
  FileUtils.mkdir_p ws.remotes_dir
98
98
  create_dir_watcher(ws.remotes_dir,
99
- excluded_paths: [/(^|#{File::SEPARATOR})\./],
100
- inotify_flags: [:recursive])
99
+ excluded_paths: [/(^|#{File::SEPARATOR})\./],
100
+ inotify_flags: [:recursive])
101
101
  end
102
102
 
103
103
  def cleanup_notifier
@@ -106,33 +106,29 @@ module Autoproj
106
106
  end
107
107
 
108
108
  def assert_watchers_available
109
- return if RbConfig::CONFIG['target_os'] =~ /linux/
109
+ return if RbConfig::CONFIG["target_os"] =~ /linux/
110
110
 
111
- puts 'error: Workspace watching not available on this platform'
111
+ puts "error: Workspace watching not available on this platform"
112
112
  exit 1
113
113
  end
114
114
 
115
115
  def setup_notifier
116
116
  assert_watchers_available
117
117
 
118
- require 'rb-inotify'
118
+ require "rb-inotify"
119
119
  @notifier = INotify::Notifier.new
120
120
  end
121
121
 
122
122
  def cleanup
123
- if @marker_io
124
- Ops.watch_cleanup_marker(@marker_io)
125
- end
126
- if @notifier
127
- cleanup_notifier
128
- end
123
+ Ops.watch_cleanup_marker(@marker_io) if @marker_io
124
+ cleanup_notifier if @notifier
129
125
  end
130
126
 
131
127
  def restart
132
128
  cleanup
133
129
  args = []
134
130
  args << "--show-events" if show_events?
135
- exec($PROGRAM_NAME, 'watch', *args)
131
+ exec($PROGRAM_NAME, "watch", *args)
136
132
  end
137
133
 
138
134
  def run(**)
@@ -146,13 +142,13 @@ module Autoproj
146
142
  setup_notifier
147
143
  start_watchers
148
144
 
149
- puts 'Watching workspace, press ^C to quit...'
145
+ puts "Watching workspace, press ^C to quit..."
150
146
  notifier.run
151
147
 
152
- puts 'Workspace changed...'
148
+ puts "Workspace changed..."
153
149
  restart
154
150
  rescue Interrupt
155
- puts 'Exiting...'
151
+ puts "Exiting..."
156
152
  ensure
157
153
  cleanup
158
154
  end