autoproj 2.13.0 → 2.15.2

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 +5 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +224 -199
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +223 -198
  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 +64 -34
  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 +213 -204
  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 +45 -39
  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 +35 -37
  58. data/lib/autoproj/cli/utility.rb +11 -10
  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 +77 -85
  65. data/lib/autoproj/default.osdeps +18 -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 +137 -130
  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 +525 -507
  80. data/lib/autoproj/ops/import.rb +76 -64
  81. data/lib/autoproj/ops/install.rb +217 -191
  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 +144 -113
  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 +127 -104
  125. data/lib/autoproj/variable_expansion.rb +7 -9
  126. data/lib/autoproj/vcs_definition.rb +35 -32
  127. data/lib/autoproj/version.rb +1 -1
  128. data/lib/autoproj/workspace.rb +142 -108
  129. data/lib/autoproj/zsh_completion.rb +8 -9
  130. data/lib/autoproj.rb +55 -55
  131. data/samples/autoproj/init.rb +1 -2
  132. metadata +80 -46
  133. data/.travis.yml +0 -24
@@ -1,7 +1,7 @@
1
- require 'autoproj/cli'
2
- require 'autoproj/cli/base'
3
- require 'autoproj/cli/status'
4
- require 'autoproj/ops/import'
1
+ require "autoproj/cli"
2
+ require "autoproj/cli/base"
3
+ require "autoproj/cli/status"
4
+ require "autoproj/ops/import"
5
5
 
6
6
  module Autoproj
7
7
  module CLI
@@ -9,13 +9,11 @@ module Autoproj
9
9
  def validate_options(selection, options)
10
10
  selection, options = super
11
11
 
12
- if from = options[:from]
12
+ if (from = options[:from])
13
13
  options[:from] = Autoproj::InstallationManifest.from_workspace_root(from)
14
14
  end
15
15
 
16
- if options[:no_deps_shortcut]
17
- options[:deps] = false
18
- end
16
+ options[:deps] = false if options[:no_deps_shortcut]
19
17
 
20
18
  if options[:aup] && !options[:config] && !options[:all] && selection.empty?
21
19
  if Dir.pwd == ws.root_dir
@@ -25,12 +23,10 @@ module Autoproj
25
23
  end
26
24
  end
27
25
 
28
- if options.delete(:force_reset)
29
- options[:reset] = :force
30
- end
26
+ options[:reset] = :force if options.delete(:force_reset)
31
27
 
32
- if mainline = options[:mainline]
33
- if mainline == 'mainline' || mainline == 'true'
28
+ if (mainline = options[:mainline])
29
+ if mainline == "mainline" || mainline == "true"
34
30
  options[:mainline] = true
35
31
  end
36
32
  end
@@ -64,7 +60,7 @@ module Autoproj
64
60
  options[:autoproj] = update_autoproj
65
61
  options[:config] = update_config
66
62
  options[:packages] = update_packages
67
- return selection, options
63
+ [selection, options]
68
64
  end
69
65
 
70
66
  def run(selected_packages, run_hook: false, report: true, ask: false, **options)
@@ -91,9 +87,7 @@ module Autoproj
91
87
  retry_count: options[:retry_count]
92
88
  )
93
89
  rescue ImportFailed => configuration_import_failure
94
- if !options[:keep_going]
95
- raise
96
- end
90
+ raise unless options[:keep_going]
97
91
  ensure
98
92
  ws.config.save
99
93
  end
@@ -104,14 +98,16 @@ module Autoproj
104
98
  else
105
99
  ws.setup_all_package_directories
106
100
  ws.finalize_package_setup
107
- command_line_selection, selected_packages = [], PackageSelection.new
101
+ command_line_selection = []
102
+ selected_packages = PackageSelection.new
108
103
  end
109
104
 
110
105
  osdeps_options = normalize_osdeps_options(
111
106
  checkout_only: options[:checkout_only],
112
107
  osdeps_mode: options[:osdeps_mode],
113
108
  osdeps: options[:osdeps],
114
- osdeps_filter_uptodate: options[:osdeps_filter_uptodate])
109
+ osdeps_filter_uptodate: options[:osdeps_filter_uptodate]
110
+ )
115
111
 
116
112
  source_packages, osdep_packages, import_failure =
117
113
  update_packages(
@@ -128,7 +124,8 @@ module Autoproj
128
124
  retry_count: options[:retry_count],
129
125
  auto_exclude: options[:auto_exclude],
130
126
  ask: ask,
131
- report: report)
127
+ report: report
128
+ )
132
129
 
133
130
  ws.finalize_setup
134
131
  ws.export_installation_manifest
@@ -141,12 +138,12 @@ module Autoproj
141
138
  if run_hook
142
139
  if options[:osdeps]
143
140
  CLI::Main.run_post_command_hook(:update, ws,
144
- source_packages: source_packages,
145
- osdep_packages: osdep_packages)
141
+ source_packages: source_packages,
142
+ osdep_packages: osdep_packages)
146
143
  else
147
144
  CLI::Main.run_post_command_hook(:update, ws,
148
- source_packages: source_packages,
149
- osdep_packages: [])
145
+ source_packages: source_packages,
146
+ osdep_packages: [])
150
147
  end
151
148
  end
152
149
 
@@ -162,7 +159,7 @@ module Autoproj
162
159
  end
163
160
  end
164
161
 
165
- return command_line_selection, source_packages, osdep_packages
162
+ [command_line_selection, source_packages, osdep_packages]
166
163
  end
167
164
 
168
165
  def finish_loading_configuration(selected_packages)
@@ -173,21 +170,22 @@ module Autoproj
173
170
  # overrides.rb files might have changed it
174
171
  ws.finalize_package_setup
175
172
  # Finally, filter out exclusions
176
- resolved_selected_packages, _ =
173
+ resolved_selected_packages, =
177
174
  resolve_user_selection(selected_packages)
178
175
  validate_user_selection(selected_packages, resolved_selected_packages)
179
176
 
180
- if !selected_packages.empty?
181
- command_line_selection = resolved_selected_packages.dup
182
- else
177
+ if selected_packages.empty?
183
178
  command_line_selection = Array.new
179
+ else
180
+ command_line_selection = resolved_selected_packages.dup
184
181
  end
185
- return command_line_selection, resolved_selected_packages
182
+ [command_line_selection, resolved_selected_packages]
186
183
  end
187
184
 
188
185
  def normalize_osdeps_options(
189
186
  checkout_only: false, osdeps: true, osdeps_mode: nil,
190
- osdeps_filter_uptodate: true)
187
+ osdeps_filter_uptodate: true
188
+ )
191
189
 
192
190
  osdeps_options = Hash[install_only: checkout_only]
193
191
  if osdeps_mode
@@ -218,7 +216,7 @@ module Autoproj
218
216
  clean = !status.unexpected &&
219
217
  (status.sync || (status.local && !status.remote))
220
218
  if clean
221
- msg = Autobuild.color('already up-to-date', :green)
219
+ msg = Autobuild.color("already up-to-date", :green)
222
220
  pkg.autobuild.message "#{msg} %s"
223
221
  return false
224
222
  end
@@ -230,7 +228,7 @@ module Autoproj
230
228
  end
231
229
 
232
230
  def lookahead(pkg)
233
- @futures[pkg] = Concurrent::Future.execute(executor: @executor) do
231
+ @futures[pkg] = Concurrent::Promises.future_on(@executor) do
234
232
  Status.status_of_package(
235
233
  pkg, snapshot: false, only_local: @only_local
236
234
  )
@@ -257,9 +255,10 @@ module Autoproj
257
255
  end
258
256
 
259
257
  ops = Autoproj::Ops::Import.new(
260
- ws, report_path: (ws.import_report_path if report))
258
+ ws, report_path: (ws.import_report_path if report)
259
+ )
261
260
  source_packages, osdep_packages =
262
- ops.import_packages(selected_packages,
261
+ ops.import_packages(selected_packages,
263
262
  checkout_only: checkout_only,
264
263
  only_local: only_local,
265
264
  reset: reset,
@@ -284,7 +283,7 @@ module Autoproj
284
283
  def setup_update_from(other_root)
285
284
  manifest.each_autobuild_package do |pkg|
286
285
  if pkg.importer.respond_to?(:pick_from_autoproj_root)
287
- if !pkg.importer.pick_from_autoproj_root(pkg, other_root)
286
+ unless pkg.importer.pick_from_autoproj_root(pkg, other_root)
288
287
  pkg.update = false
289
288
  end
290
289
  else
@@ -295,4 +294,3 @@ module Autoproj
295
294
  end
296
295
  end
297
296
  end
298
-
@@ -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,7 +69,7 @@ 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
74
  puts(format(out_format, name, (!!enabled).to_s, (!!available).to_s)) # rubocop:disable Style/DoubleNegation
74
75
  end
@@ -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
 
@@ -121,13 +122,13 @@ module Autoproj
121
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
  }
132
133
  # rubocop:enable Style/DoubleNegation
133
134
  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
@@ -1,15 +1,15 @@
1
- require 'autoproj'
2
- require 'autoproj/ops/cached_env'
3
- require 'autoproj/ops/which'
4
- require 'autoproj/ops/watch'
1
+ require "autoproj"
2
+ require "autoproj/ops/cached_env"
3
+ require "autoproj/ops/which"
4
+ require "autoproj/ops/watch"
5
5
 
6
6
  module Autoproj
7
7
  module CLI
8
8
  class Which
9
9
  def initialize
10
10
  @root_dir = Autoproj.find_workspace_dir
11
- if !@root_dir
12
- require 'autoproj/workspace'
11
+ unless @root_dir
12
+ require "autoproj/workspace"
13
13
  # Will do all sorts of error reporting,
14
14
  # or may be able to resolve
15
15
  @root_dir = Workspace.default.root_dir
@@ -18,20 +18,18 @@ module Autoproj
18
18
 
19
19
  def load_cached_env
20
20
  env = Ops.load_cached_env(@root_dir)
21
- return if !env
21
+ return unless env
22
22
 
23
- Autobuild::Environment.
24
- environment_from_export(env, ENV)
23
+ Autobuild::Environment
24
+ .environment_from_export(env, ENV)
25
25
  end
26
26
 
27
27
  def run(cmd, use_cached_env: Ops.watch_running?(@root_dir))
28
- if use_cached_env
29
- env = load_cached_env
30
- end
28
+ env = load_cached_env if use_cached_env
31
29
 
32
- if !env
33
- require 'autoproj'
34
- require 'autoproj/cli/inspection_tool'
30
+ unless env
31
+ require "autoproj"
32
+ require "autoproj/cli/inspection_tool"
35
33
  ws = Workspace.from_dir(@root_dir)
36
34
  loader = InspectionTool.new(ws)
37
35
  loader.initialize_and_load
@@ -39,17 +37,15 @@ module Autoproj
39
37
  env = ws.full_env.resolved_env
40
38
  end
41
39
 
42
- path = env['PATH'].split(File::PATH_SEPARATOR)
40
+ path = env["PATH"].split(File::PATH_SEPARATOR)
43
41
  puts Ops.which(cmd, path_entries: path)
44
42
  rescue ExecutableNotFound => e
45
- require 'autoproj' # make sure everything is available for error reporting
43
+ require "autoproj" # make sure everything is available for error reporting
46
44
  raise CLIInvalidArguments, e.message, e.backtrace
47
45
  rescue Exception
48
- require 'autoproj' # make sure everything is available for error reporting
46
+ require "autoproj" # make sure everything is available for error reporting
49
47
  raise
50
48
  end
51
49
  end
52
50
  end
53
51
  end
54
-
55
-
data/lib/autoproj/cli.rb CHANGED
@@ -5,10 +5,13 @@ module Autoproj
5
5
  true
6
6
  end
7
7
  end
8
+
8
9
  class CLIInvalidArguments < CLIException
9
10
  end
11
+
10
12
  class CLIAmbiguousArguments < CLIException
11
13
  end
14
+
12
15
  class CLIInvalidSelection < CLIException
13
16
  end
14
17
 
@@ -20,10 +23,9 @@ module Autoproj
20
23
  :find_files
21
24
  end
22
25
 
23
- Gem.send(finder_name, 'autoproj-*', true).each do |path|
26
+ Gem.send(finder_name, "autoproj-*", true).each do |path|
24
27
  require path
25
28
  end
26
29
  end
27
30
  end
28
31
  end
29
-