autobuild 1.23.1 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb4af40b45b8a0e1185e81a0cf63a4cf75728d1360290b0dfb3bb194bd409361
4
- data.tar.gz: 1e2a3d4f44a08126ca0ca39fe00e15c31430da623f83852827159cabd880b2e2
3
+ metadata.gz: 56a551f16208e61f38188d81b0b944ef6ba663fbc3155ae7e55b009f2adda2e6
4
+ data.tar.gz: 60e5b9d1b8ffe8ff4e35d006960a251ef82467ee5d17adcb9d9d21e2e7f47b15
5
5
  SHA512:
6
- metadata.gz: 6b363c75454df74373af48e1fa994a1a92471f076184bbffa85867f6f6c346d61aac1469621c56f331646695c817c445bb1b1198aee063d79ad95a9da25437d5
7
- data.tar.gz: 84751817159e35967dcaf0b7d32e13b46e9c660ec6c649b8eac0cce97a33003f50fef2a05502cbd667025143b763cc69688f0a96805b9f2764848cbc4c15785b
6
+ metadata.gz: 30af86ba246a653daac4299675fe4b248b36b2d30750feefd567dc32c6768b9f4b60f877021253699336c5d01c54b69f1d7db6808a6d49ea12ff612f425ca01c
7
+ data.tar.gz: 16e7849423378e7e5e89f0e40e7cc77173e87290954734aa86195cf15547388bce6a7b234aaf8857593e2d513b9daf4634759026706a6f2e54eb2044b7ee8b96
@@ -10,7 +10,26 @@ module Autobuild
10
10
  # Exception raised when a network access is needed while only_local is true
11
11
  class NetworkAccessNeeded < RuntimeError; end
12
12
 
13
+ @default_fingerprint_mode = "commit"
14
+
13
15
  class << self
16
+ # Sets the single_branch option globally for all Git importers
17
+ # This can can be overriden in the oporter options
18
+ attr_writer :single_branch
19
+
20
+ # Whether single_branch is enabled globally
21
+ def single_branch?
22
+ !!@single_branch
23
+ end
24
+
25
+ # Sets shallow clones globally (applies to submodules as well)
26
+ attr_writer :shallow
27
+
28
+ # Whether shallow clones is enabled globally
29
+ def shallow?
30
+ !!@shallow
31
+ end
32
+
14
33
  # Sets the default alternates path used by all Git importers
15
34
  #
16
35
  # Setting it explicitly overrides any value we get from the
@@ -44,6 +63,18 @@ module Autobuild
44
63
  Array.new
45
64
  end
46
65
  end
66
+
67
+ # What git repository fingerprinting uses as reference
68
+ #
69
+ # Can either be
70
+ # - "commit" (the default). Use the commit hash of HEAD
71
+ # - "tree". Use the tree hash. This will return the same fingerprint
72
+ # for new commits that do not change the source code. However, it
73
+ # will fail to detect changes to the working copy that are due
74
+ # to git checkout filters.
75
+ #
76
+ # @return [String]
77
+ attr_accessor :default_fingerprint_mode
47
78
  end
48
79
 
49
80
  def self.default_config
@@ -142,17 +173,22 @@ module Autobuild
142
173
  Autobuild.warn " branch: 'master'"
143
174
  end
144
175
 
145
- gitopts, common = Kernel.filter_options options,
146
- push_to: nil,
147
- branch: nil,
148
- local_branch: nil,
149
- remote_branch: nil,
150
- tag: nil,
151
- commit: nil,
152
- repository_id: nil,
153
- source_id: nil,
154
- with_submodules: false,
155
- single_branch: false
176
+ gitopts, common = Kernel.filter_options(
177
+ options,
178
+ push_to: nil,
179
+ branch: nil,
180
+ local_branch: nil,
181
+ remote_branch: nil,
182
+ tag: nil,
183
+ commit: nil,
184
+ repository_id: nil,
185
+ source_id: nil,
186
+ with_submodules: false,
187
+ fingerprint_mode: Git.default_fingerprint_mode,
188
+ single_branch: Git.single_branch?,
189
+ shallow: Git.shallow?
190
+ )
191
+
156
192
  if gitopts[:branch] && branch
157
193
  raise ConfigException, "git branch specified with both the option hash "\
158
194
  "and the explicit parameter"
@@ -162,6 +198,7 @@ module Autobuild
162
198
  super(common)
163
199
 
164
200
  @single_branch = gitopts[:single_branch]
201
+ @shallow = gitopts[:shallow]
165
202
  @with_submodules = gitopts.delete(:with_submodules)
166
203
  @alternates =
167
204
  if @with_submodules
@@ -172,12 +209,13 @@ module Autobuild
172
209
 
173
210
  @remote_name = 'autobuild'
174
211
  @push_to = nil
212
+ @fingerprint_mode = gitopts[:fingerprint_mode]
175
213
  relocate(repository, gitopts)
176
214
  @additional_remotes = Array.new
177
215
  end
178
216
 
179
217
  def vcs_fingerprint(package)
180
- rev_parse(package, 'HEAD')
218
+ rev_parse(package, "HEAD", @fingerprint_mode)
181
219
  end
182
220
 
183
221
  # The name of the remote that should be set up by the importer
@@ -286,9 +324,17 @@ module Autobuild
286
324
  @single_branch
287
325
  end
288
326
 
327
+ # Whether clones should be shallow
328
+ def shallow?
329
+ @shallow
330
+ end
331
+
289
332
  # Set the {#single_branch?} predicate
290
333
  attr_writer :single_branch
291
334
 
335
+ # Set the {#shallow?} predicate
336
+ attr_writer :shallow
337
+
292
338
  # @api private
293
339
  #
294
340
  # Verifies that the package's {Package#importdir} points to a git
@@ -1255,19 +1301,60 @@ module Autobuild
1255
1301
  @lfs_installed = status.success?
1256
1302
  end
1257
1303
 
1304
+ def validate_shallow(package)
1305
+ return false unless shallow?
1306
+
1307
+ if commit
1308
+ Autoproj.warn "#{package.name}: "\
1309
+ "Cannot pin a commit while doing a shallow clone"
1310
+ return false
1311
+ end
1312
+ if tag && !single_branch?
1313
+ Autoproj.warn "#{package.name}: "\
1314
+ "Cannot pin a tag while doing a shallow clone"
1315
+ return false
1316
+ end
1317
+ if @remote_branch
1318
+ Autoproj.warn "#{package.name}: "\
1319
+ "Cannot use remote_branch while doing a shallow clone"
1320
+ return false
1321
+ end
1322
+ true
1323
+ end
1324
+
1258
1325
  def checkout(package, _options = Hash.new)
1326
+ shallow_clone = validate_shallow(package)
1327
+
1259
1328
  base_dir = File.expand_path('..', package.importdir)
1260
1329
  FileUtils.mkdir_p(base_dir) unless File.directory?(base_dir)
1261
1330
 
1262
1331
  clone_options = Array.new
1263
- clone_options << '--recurse-submodules' if with_submodules?
1332
+ if with_submodules?
1333
+ clone_options << '--recurse-submodules'
1334
+ clone_options << '--shallow-submodules' if shallow_clone
1335
+ end
1336
+
1337
+ clone_options << '--depth' << '1' if shallow_clone
1338
+
1264
1339
  if single_branch?
1265
- if remote_branch.start_with?("refs/")
1266
- raise ArgumentError, "you cannot provide a full ref for"\
1267
- " the remote branch while cloning a single branch"
1340
+ if tag
1341
+ if tag.start_with?("refs/")
1342
+ raise ArgumentError, "you cannot provide a full ref for"\
1343
+ " the tag while cloning a single branch"
1344
+ end
1345
+ clone_options << "--branch=#{tag}"
1346
+ elsif remote_branch
1347
+ if remote_branch.start_with?("refs/")
1348
+ raise ArgumentError, "you cannot provide a full ref for"\
1349
+ " the remote branch while cloning a single branch"
1350
+ end
1351
+ clone_options << "--branch=#{remote_branch}"
1268
1352
  end
1269
- clone_options << "--branch=#{remote_branch}" << "--single-branch"
1353
+ clone_options << "--single-branch"
1354
+ elsif shallow_clone
1355
+ clone_options << "--no-single-branch"
1270
1356
  end
1357
+
1271
1358
  each_alternate_path(package) do |path|
1272
1359
  clone_options << '--reference' << path
1273
1360
  end
@@ -1278,7 +1365,7 @@ module Autobuild
1278
1365
  Autobuild.tool('git'), 'clone', '-o', remote_name, *clone_options,
1279
1366
  repository, package.importdir, retry: true)
1280
1367
 
1281
- update_remotes_configuration(package)
1368
+ update_remotes_configuration(package, only_local: false)
1282
1369
  update(package, only_local: !remote_branch.start_with?("refs/"),
1283
1370
  reset: :force)
1284
1371
  if with_submodules?
@@ -269,7 +269,14 @@ module Autobuild
269
269
  run('doc', Autobuild.tool(:doxygen), doxyfile)
270
270
  end
271
271
 
272
- def common_utility_handling(utility, target, *args, start_msg, done_msg)
272
+ def common_utility_handling( # rubocop:disable Metrics/ParameterLists
273
+ utility,
274
+ target,
275
+ *args,
276
+ start_msg,
277
+ done_msg,
278
+ post_process: nil
279
+ )
273
280
  utility.source_ref_dir = builddir
274
281
  utility.task do
275
282
  progress_start start_msg, :done_message => done_msg do
@@ -284,6 +291,24 @@ module Autobuild
284
291
  end
285
292
  yield if block_given?
286
293
  end
294
+
295
+ post_process&.call
296
+ end
297
+ end
298
+
299
+ def with_coverage(&block)
300
+ @with_coverage ||= block
301
+ end
302
+
303
+ def coverage_block
304
+ proc do
305
+ next unless test_utility.coverage_enabled?
306
+ next unless @with_coverage
307
+
308
+ progress_start "generating coverage report for %s",
309
+ done_message: "generated coverage report for %s" do
310
+ @with_coverage.call
311
+ end
287
312
  end
288
313
  end
289
314
 
@@ -299,7 +324,8 @@ module Autobuild
299
324
  common_utility_handling(
300
325
  test_utility, target, "ARGS=-V",
301
326
  "running tests for %s",
302
- "successfully ran tests for %s", &block)
327
+ "successfully ran tests for %s",
328
+ post_process: coverage_block, &block)
303
329
  end
304
330
 
305
331
  CMAKE_EQVS = {
@@ -1,3 +1,3 @@
1
1
  module Autobuild
2
- VERSION = "1.23.1".freeze unless defined? Autobuild::VERSION
2
+ VERSION = "1.24.0".freeze unless defined? Autobuild::VERSION
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.1
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby