autobuild 1.20.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) 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 +14 -7
  5. data/autobuild.gemspec +7 -6
  6. data/bin/autobuild +1 -1
  7. data/lib/autobuild/build_logfile.rb +1 -2
  8. data/lib/autobuild/config.rb +5 -5
  9. data/lib/autobuild/environment.rb +126 -58
  10. data/lib/autobuild/exceptions.rb +13 -6
  11. data/lib/autobuild/import/archive.rb +33 -23
  12. data/lib/autobuild/import/cvs.rb +6 -6
  13. data/lib/autobuild/import/darcs.rb +4 -4
  14. data/lib/autobuild/import/git-lfs.rb +4 -4
  15. data/lib/autobuild/import/git.rb +155 -73
  16. data/lib/autobuild/import/hg.rb +7 -7
  17. data/lib/autobuild/import/svn.rb +17 -10
  18. data/lib/autobuild/importer.rb +37 -39
  19. data/lib/autobuild/mail_reporter.rb +5 -2
  20. data/lib/autobuild/package.rb +28 -15
  21. data/lib/autobuild/packages/autotools.rb +6 -10
  22. data/lib/autobuild/packages/cmake.rb +13 -9
  23. data/lib/autobuild/packages/dummy.rb +0 -4
  24. data/lib/autobuild/packages/gnumake.rb +1 -1
  25. data/lib/autobuild/packages/orogen.rb +11 -4
  26. data/lib/autobuild/packages/pkgconfig.rb +2 -2
  27. data/lib/autobuild/packages/python.rb +19 -8
  28. data/lib/autobuild/packages/ruby.rb +5 -5
  29. data/lib/autobuild/parallel.rb +9 -17
  30. data/lib/autobuild/pkgconfig.rb +1 -0
  31. data/lib/autobuild/progress_display.rb +67 -43
  32. data/lib/autobuild/rake_task_extension.rb +6 -0
  33. data/lib/autobuild/reporting.rb +15 -9
  34. data/lib/autobuild/subcommand.rb +30 -26
  35. data/lib/autobuild/test_utility.rb +6 -3
  36. data/lib/autobuild/timestamps.rb +3 -3
  37. data/lib/autobuild/utility.rb +22 -4
  38. data/lib/autobuild/version.rb +1 -1
  39. data/lib/autobuild.rb +0 -3
  40. metadata +28 -26
  41. data/.travis.yml +0 -19
@@ -7,6 +7,9 @@ require 'English'
7
7
 
8
8
  module Autobuild
9
9
  class Git < Importer
10
+ # Exception raised when a network access is needed while only_local is true
11
+ class NetworkAccessNeeded < RuntimeError; end
12
+
10
13
  class << self
11
14
  # Sets the default alternates path used by all Git importers
12
15
  #
@@ -37,7 +40,8 @@ module Autobuild
37
40
  @default_alternates = cache_dirs.map do |path|
38
41
  File.join(File.expand_path(path), '%s')
39
42
  end
40
- else Array.new
43
+ else
44
+ Array.new
41
45
  end
42
46
  end
43
47
  end
@@ -54,7 +58,7 @@ module Autobuild
54
58
  def self.version
55
59
  version = Subprocess.run('git', 'setup', Autobuild.tool(:git), '--version').
56
60
  first
57
- if version =~ /^git version (\d[\d\.]+)/
61
+ if version =~ /^git version (\d[\d.]+)/
58
62
  $1.split(".").map { |i| Integer(i) }
59
63
  else
60
64
  raise ArgumentError, "cannot parse git version string #{version}, "\
@@ -139,16 +143,16 @@ module Autobuild
139
143
  end
140
144
 
141
145
  gitopts, common = Kernel.filter_options options,
142
- push_to: nil,
143
- branch: nil,
144
- local_branch: nil,
145
- remote_branch: nil,
146
- tag: nil,
147
- commit: nil,
148
- repository_id: nil,
149
- source_id: nil,
150
- with_submodules: false,
151
- single_branch: false
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
152
156
  if gitopts[:branch] && branch
153
157
  raise ConfigException, "git branch specified with both the option hash "\
154
158
  "and the explicit parameter"
@@ -293,6 +297,68 @@ module Autobuild
293
297
  git_dir(package, true)
294
298
  end
295
299
 
300
+ # Return the remote head branch from local copy if exists, if not return nil
301
+ #
302
+ # @param [Package] package
303
+ def try_resolve_remote_head_from_local(package)
304
+ ls_local_string = run_git_bare(
305
+ package, 'symbolic-ref',
306
+ "refs/remotes/#{@remote_name}/HEAD"
307
+ ).first.strip
308
+ local_remote_head = ls_local_string.match("refs/remotes/#{@remote_name}/(.*)")
309
+ local_remote_head ? local_remote_head[1] : nil
310
+ rescue Autobuild::SubcommandFailed # rubocop:disable Lint/SuppressedException
311
+ end
312
+
313
+ # Return the remote head branch from server if exists, if not return 'master'
314
+ #
315
+ # @param [Package] package
316
+ def try_resolve_remote_head_from_server(package)
317
+ ls_remote_string = package.run(
318
+ :import,
319
+ Autobuild.tool('git'), 'ls-remote', '--symref', repository
320
+ ).first.strip
321
+ server_remote_head =
322
+ ls_remote_string.match("ref:[^A-z]refs/heads/(.*)[^A-z]HEAD")
323
+ server_remote_head ? server_remote_head[1] : 'master'
324
+ end
325
+
326
+ # Return default local branch if exists, if not return the default remote branch
327
+ #
328
+ # @param [Package] package
329
+ def resolve_remote_head(package, only_local: false)
330
+ try_resolve_remote_head_from_local(package) ||
331
+ (!only_local && try_resolve_remote_head_from_server(package))
332
+ end
333
+
334
+ # Whether both the local and remote branches are known
335
+ #
336
+ # See documentation of {#resolve_all_branches}
337
+ def has_all_branches?
338
+ remote_branch && local_branch
339
+ end
340
+
341
+ # Resolve branches based on the remote's HEAD
342
+ #
343
+ # Since GitHub (and others) decided to change the name of the "default"
344
+ # branch, we can't assume that master is ... well ... master.
345
+ #
346
+ # For this reason, a Git importer does not have a built-in default.
347
+ # If the branch(es) are not provided explicitly, the importer will
348
+ # call this method to guess the name of the default branch instead.
349
+ #
350
+ # Call {#has_all_branches?} to determine whether it is necessary
351
+ def resolve_all_branches(package, only_local: false)
352
+ default_branch = resolve_remote_head(package, only_local: only_local)
353
+ unless default_branch
354
+ raise NetworkAccessNeeded,
355
+ "determining the remote branch would require access to "\
356
+ "the network, and only_local is true"
357
+ end
358
+
359
+ relocate(repository, default_branch: default_branch)
360
+ end
361
+
296
362
  # @api private
297
363
  #
298
364
  # Resolves the git directory associated with path, and tells whether it
@@ -366,12 +432,12 @@ module Autobuild
366
432
  def self.validate_git_dir(package, require_working_copy, _dir, style)
367
433
  if !style
368
434
  raise ConfigException.new(package, 'import', retry: false),
369
- "while importing #{package.name}, #{package.importdir} "\
370
- "does not point to a git repository"
435
+ "while importing #{package.name}, #{package.importdir} "\
436
+ "does not point to a git repository"
371
437
  elsif require_working_copy && (style == :bare)
372
438
  raise ConfigException.new(package, 'import', retry: false),
373
- "while importing #{package.name}, #{package.importdir} "\
374
- "points to a bare git repository but a working copy was required"
439
+ "while importing #{package.name}, #{package.importdir} "\
440
+ "points to a bare git repository but a working copy was required"
375
441
  end
376
442
  end
377
443
 
@@ -476,22 +542,28 @@ module Autobuild
476
542
  # @api private
477
543
  #
478
544
  # Set a remote up in the repositorie's configuration
479
- def setup_remote(package, remote_name, repository, push_to = repository)
545
+ def setup_remote(
546
+ package, remote_name, repository, push_to = repository,
547
+ only_local: true
548
+ )
549
+ resolve_all_branches(package, only_local: only_local) unless has_all_branches?
550
+
480
551
  run_git_bare(package, 'config', '--replace-all',
481
- "remote.#{remote_name}.url", repository)
552
+ "remote.#{remote_name}.url", repository)
482
553
  run_git_bare(package, 'config', '--replace-all',
483
- "remote.#{remote_name}.pushurl", push_to || repository)
554
+ "remote.#{remote_name}.pushurl", push_to || repository)
484
555
  run_git_bare(package, 'config', '--replace-all',
485
- "remote.#{remote_name}.fetch",
486
- "+refs/heads/*:refs/remotes/#{remote_name}/*")
556
+ "remote.#{remote_name}.fetch",
557
+ "+refs/heads/*:refs/remotes/#{remote_name}/*")
487
558
 
488
559
  if remote_branch && local_branch
560
+ remote_ref = remote_branch_to_ref(remote_branch)
489
561
  run_git_bare(package, 'config', '--replace-all',
490
- "remote.#{remote_name}.push",
491
- "refs/heads/#{local_branch}:#{remote_branch_to_ref(remote_branch)}")
562
+ "remote.#{remote_name}.push",
563
+ "refs/heads/#{local_branch}:#{remote_ref}")
492
564
  else
493
565
  run_git_bare(package, 'config', '--replace-all',
494
- "remote.#{remote_name}.push", "refs/heads/*:refs/heads/*")
566
+ "remote.#{remote_name}.push", "refs/heads/*:refs/heads/*")
495
567
  end
496
568
  end
497
569
 
@@ -510,23 +582,24 @@ module Autobuild
510
582
  # @api private
511
583
  #
512
584
  # Updates the git repository's configuration for the target remote
513
- def update_remotes_configuration(package)
585
+ def update_remotes_configuration(package, only_local: true)
514
586
  each_configured_remote do |*args|
515
- setup_remote(package, *args)
587
+ setup_remote(package, *args, only_local: only_local)
516
588
  end
517
589
 
518
590
  if local_branch
519
591
  run_git_bare(package, 'config', '--replace-all',
520
- "branch.#{local_branch}.remote", remote_name)
592
+ "branch.#{local_branch}.remote", remote_name)
521
593
  run_git_bare(package, 'config', '--replace-all',
522
- "branch.#{local_branch}.merge", remote_branch_to_ref(local_branch))
594
+ "branch.#{local_branch}.merge",
595
+ remote_branch_to_ref(local_branch))
523
596
  end
524
597
  end
525
598
 
526
599
  # Resolve a commit ref to a tag or commit ID
527
600
  def describe_rev(package, rev)
528
601
  tag = run_git_bare(package, 'describe',
529
- '--tags', '--exact-match', rev).first.strip
602
+ '--tags', '--exact-match', rev).first.strip
530
603
  [true, tag.encode('UTF-8')]
531
604
  rescue Autobuild::SubcommandFailed
532
605
  commit = rev_parse(package, rev)
@@ -584,7 +657,7 @@ module Autobuild
584
657
  refspec.zip(fetched_commits).each do |spec, commit_id|
585
658
  if spec =~ %r{^refs/heads/(.*)$}
586
659
  run_git_bare(package, 'update-ref', "-m", "updated by autobuild",
587
- "refs/remotes/#{remote_name}/#{$1}", commit_id)
660
+ "refs/remotes/#{remote_name}/#{$1}", commit_id)
588
661
  end
589
662
  end
590
663
 
@@ -641,7 +714,7 @@ module Autobuild
641
714
  run_git_bare(package, 'show-ref', '-s', refspec).first.strip
642
715
  rescue SubcommandFailed
643
716
  raise PackageException.new(package, "import"),
644
- "cannot resolve #{refspec}"
717
+ "cannot resolve #{refspec}"
645
718
  end
646
719
  else
647
720
  refspec =
@@ -650,7 +723,7 @@ module Autobuild
650
723
  remote_branch_to_ref(remote_branch)
651
724
  begin fetch_remote(package, refspec: refspec)
652
725
  rescue Exception => e
653
- return fallback(e, package, :status, package, only_local)
726
+ fallback(e, package, :status, package, only_local)
654
727
  end
655
728
  end
656
729
  end
@@ -666,6 +739,8 @@ module Autobuild
666
739
  end
667
740
 
668
741
  validate_importdir(package)
742
+ resolve_all_branches(package, only_local: only_local) unless has_all_branches?
743
+
669
744
  _pinned_state, target_commit, = determine_target_state(
670
745
  package, only_local: only_local)
671
746
 
@@ -690,23 +765,25 @@ module Autobuild
690
765
  rescue SubcommandFailed => e
691
766
  if e.status == 1
692
767
  false
693
- else raise
768
+ else
769
+ raise
694
770
  end
695
771
  end
696
772
 
697
773
  def has_branch?(package, branch_name)
698
774
  run_git_bare(package, 'show-ref', '-q', '--verify',
699
- remote_branch_to_ref(branch_name))
775
+ remote_branch_to_ref(branch_name))
700
776
  true
701
777
  rescue SubcommandFailed => e
702
778
  if e.status == 1
703
779
  false
704
- else raise
780
+ else
781
+ raise
705
782
  end
706
783
  end
707
784
 
708
785
  def has_local_branch?(package)
709
- has_branch?(package, local_branch)
786
+ has_branch?(package, local_branch) if local_branch
710
787
  end
711
788
 
712
789
  def detached_head?(package)
@@ -714,6 +791,8 @@ module Autobuild
714
791
  end
715
792
 
716
793
  private def remote_branch_to_ref(branch)
794
+ return unless branch
795
+
717
796
  if branch.start_with?("refs/")
718
797
  branch
719
798
  else
@@ -750,9 +829,7 @@ module Autobuild
750
829
  #
751
830
  # This is the value returned by {Git#status}
752
831
  class Status < Importer::Status
753
- attr_reader :fetch_commit
754
- attr_reader :head_commit
755
- attr_reader :common_commit
832
+ attr_reader :fetch_commit, :head_commit, :common_commit
756
833
 
757
834
  def initialize(package, status, remote_commit, local_commit, common_commit)
758
835
  super()
@@ -797,8 +874,8 @@ module Autobuild
797
874
  run_git_bare(package, 'rev-parse', '-q', '--verify', name).first
798
875
  rescue Autobuild::SubcommandFailed
799
876
  raise PackageException.new(package, 'import'),
800
- "failed to resolve #{name}. "\
801
- "Are you sure this commit, branch or tag exists ?"
877
+ "failed to resolve #{name}. "\
878
+ "Are you sure this commit, branch or tag exists ?"
802
879
  end
803
880
 
804
881
  # Returns the file's conents at a certain commit
@@ -811,7 +888,7 @@ module Autobuild
811
888
  run_git_bare(package, 'show', "#{commit}:#{path}").join("\n")
812
889
  rescue Autobuild::SubcommandFailed
813
890
  raise PackageException.new(package, 'import'),
814
- "failed to either resolve commit #{commit} or file #{path}"
891
+ "failed to either resolve commit #{commit} or file #{path}"
815
892
  end
816
893
 
817
894
  # Tests whether a commit is already present in a given history
@@ -845,7 +922,7 @@ module Autobuild
845
922
  def describe_commit_on_remote(package, rev = 'HEAD', options = Hash.new)
846
923
  rev = rev.to_str
847
924
  options = Kernel.validate_options options,
848
- tags: true
925
+ tags: true
849
926
 
850
927
  commit_id = rev_parse(package, rev)
851
928
 
@@ -875,15 +952,13 @@ module Autobuild
875
952
  end
876
953
 
877
954
  remote_refs.delete_if do |rev_name, rev_id|
878
- begin
879
955
  if commit_present_in?(package, commit_id, rev_id)
880
956
  return rev_name
881
957
  else
882
958
  true
883
959
  end
884
- rescue PackageException
960
+ rescue PackageException
885
961
  false
886
- end
887
962
  end
888
963
 
889
964
  unless remote_refs.empty?
@@ -909,7 +984,7 @@ module Autobuild
909
984
  def merge_status(package, fetch_commit, reference_commit = "HEAD")
910
985
  begin
911
986
  common_commit = run_git_bare(package, 'merge-base',
912
- reference_commit, fetch_commit).first.strip
987
+ reference_commit, fetch_commit).first.strip
913
988
  rescue Exception
914
989
  raise PackageException.new(package, 'import'), "failed to find "\
915
990
  "the merge-base between #{reference_commit} and #{fetch_commit}. "\
@@ -942,13 +1017,14 @@ module Autobuild
942
1017
  # @return [void]
943
1018
  def update_alternates(package)
944
1019
  alternates_path = File.join(git_dir(package, false),
945
- 'objects', 'info', 'alternates')
1020
+ 'objects', 'info', 'alternates')
946
1021
  current_alternates =
947
1022
  if File.file?(alternates_path)
948
1023
  File.readlines(alternates_path)
949
1024
  .map(&:strip)
950
1025
  .find_all { |l| !l.empty? }
951
- else Array.new
1026
+ else
1027
+ Array.new
952
1028
  end
953
1029
 
954
1030
  alternates = each_alternate_path(package).map do |path|
@@ -1007,18 +1083,18 @@ module Autobuild
1007
1083
  # changes
1008
1084
  unless commit_present_in?(package, current_head, fetch_commit)
1009
1085
  raise ImporterCannotReset.new(package, 'import'),
1010
- "branch #{local_branch} of #{package.name} contains"\
1011
- " commits that do not seem to be present on the branch"\
1012
- " #{remote_branch} of the remote repository. I can't"\
1013
- " go on as it could make you lose some stuff. Update"\
1014
- " the remote branch in your overrides, push your"\
1015
- " changes or reset to the remote commit manually"\
1016
- " before trying again"
1086
+ "branch #{local_branch} of #{package.name} contains"\
1087
+ " commits that do not seem to be present on the branch"\
1088
+ " #{remote_branch} of the remote repository. I can't"\
1089
+ " go on as it could make you lose some stuff. Update"\
1090
+ " the remote branch in your overrides, push your"\
1091
+ " changes or reset to the remote commit manually"\
1092
+ " before trying again"
1017
1093
  end
1018
1094
  end
1019
1095
 
1020
1096
  package.message format(" %%s: resetting branch %<branch>s to %<commit>s",
1021
- branch: local_branch, commit: target_commit)
1097
+ branch: local_branch, commit: target_commit)
1022
1098
  # I don't use a reset --hard here as it would add even more
1023
1099
  # restrictions on when we can do the operation (as we would refuse
1024
1100
  # doing it if there are local changes). The checkout creates a
@@ -1029,7 +1105,7 @@ module Autobuild
1029
1105
  begin
1030
1106
  run_git(package, 'checkout', target_commit)
1031
1107
  run_git(package, 'update-ref', "refs/heads/#{local_branch}",
1032
- resolved_target_commit)
1108
+ resolved_target_commit)
1033
1109
  run_git(package, 'symbolic-ref', "HEAD", "refs/heads/#{local_branch}")
1034
1110
  rescue ::Exception
1035
1111
  run_git(package, 'symbolic-ref', "HEAD", target_commit)
@@ -1065,6 +1141,9 @@ module Autobuild
1065
1141
  # @option (see Package#update)
1066
1142
  def update(package, options = Hash.new)
1067
1143
  validate_importdir(package)
1144
+
1145
+ resolve_all_branches(package) unless has_all_branches?
1146
+
1068
1147
  only_local = options.fetch(:only_local, false)
1069
1148
  reset = options.fetch(:reset, false)
1070
1149
 
@@ -1084,20 +1163,21 @@ module Autobuild
1084
1163
  end
1085
1164
 
1086
1165
  unless pin_is_uptodate
1087
- fetch_commit ||= current_remote_commit(package,
1088
- only_local: only_local,
1089
- refspec: [remote_branch_to_ref(remote_branch), tag])
1166
+ fetch_commit ||= current_remote_commit(
1167
+ package, only_local: only_local,
1168
+ refspec: [remote_branch_to_ref(remote_branch), tag]
1169
+ )
1090
1170
  did_update =
1091
1171
  if reset
1092
1172
  reset_head_to_commit(package, target_commit, fetch_commit,
1093
- force: (reset == :force))
1173
+ force: (reset == :force))
1094
1174
  else
1095
1175
  merge_if_simple(package, target_commit)
1096
1176
  end
1097
1177
  end
1098
1178
 
1099
1179
  if !only_local && with_submodules?
1100
- run_git(package, "submodule", "update", '--init')
1180
+ run_git(package, "submodule", "update", '--init', '--recursive')
1101
1181
  did_update = true
1102
1182
  end
1103
1183
 
@@ -1107,12 +1187,12 @@ module Autobuild
1107
1187
  private def ensure_on_local_branch(package, target_commit)
1108
1188
  if !has_local_branch?(package)
1109
1189
  package.message format("%%s: checking out branch %<branch>s",
1110
- branch: local_branch)
1190
+ branch: local_branch)
1111
1191
  run_git(package, 'checkout', '-b', local_branch, target_commit)
1112
1192
  true
1113
1193
  elsif !on_local_branch?(package)
1114
1194
  package.message format("%%s: switching to branch %<branch>s",
1115
- branch: local_branch)
1195
+ branch: local_branch)
1116
1196
  run_git(package, 'checkout', local_branch)
1117
1197
  true
1118
1198
  else
@@ -1195,28 +1275,30 @@ module Autobuild
1195
1275
  clone_options << "--config=#{key}=#{value}"
1196
1276
  end
1197
1277
  package.run(:import,
1198
- Autobuild.tool('git'), 'clone', '-o', remote_name, *clone_options,
1199
- repository, package.importdir, retry: true)
1278
+ Autobuild.tool('git'), 'clone', '-o', remote_name, *clone_options,
1279
+ repository, package.importdir, retry: true)
1200
1280
 
1201
1281
  update_remotes_configuration(package)
1202
1282
  update(package, only_local: !remote_branch.start_with?("refs/"),
1203
1283
  reset: :force)
1204
- run_git(package, "submodule", "update", '--init') if with_submodules?
1284
+ if with_submodules?
1285
+ run_git(package, "submodule", "update", '--init', '--recursive')
1286
+ end
1205
1287
  end
1206
1288
 
1207
1289
  # Changes the repository this importer is pointing to
1208
1290
  def relocate(repository, options = Hash.new)
1209
- options = Hash[options.map { |k, v| [k.to_sym, v] }]
1291
+ options = options.transform_keys(&:to_sym)
1210
1292
 
1211
1293
  local_branch =
1212
1294
  options[:local_branch] || options[:branch] ||
1213
- self.local_branch || 'master'
1295
+ self.local_branch || options[:default_branch] || nil
1214
1296
  remote_branch =
1215
1297
  options[:remote_branch] || options[:branch] ||
1216
- self.remote_branch || 'master'
1217
- if local_branch.start_with?("refs/")
1298
+ self.remote_branch || options[:default_branch] || nil
1299
+ if local_branch&.start_with?("refs/")
1218
1300
  raise ArgumentError, "you cannot provide a full ref for"\
1219
- " the local branch, only for the remote branch"
1301
+ " the local branch, only for the remote branch"
1220
1302
  end
1221
1303
 
1222
1304
  @push_to = options[:push_to] || @push_to
@@ -17,9 +17,9 @@ module Autobuild
17
17
  # @option options [String] :branch (default) the branch to track
18
18
  def initialize(repository, options = {})
19
19
  hgopts, _common = Kernel.filter_options options,
20
- branch: 'default'
20
+ branch: 'default'
21
21
  sourceopts, common = Kernel.filter_options options,
22
- :repository_id, :source_id
22
+ :repository_id, :source_id
23
23
 
24
24
  super(common)
25
25
  @branch = hgopts[:branch]
@@ -48,8 +48,8 @@ module Autobuild
48
48
  def validate_importdir(package)
49
49
  unless File.directory?(File.join(package.importdir, '.hg'))
50
50
  raise ConfigException.new(package, 'import'),
51
- "while importing #{package.name}, "\
52
- "#{package.importdir} is not a hg repository"
51
+ "while importing #{package.name}, "\
52
+ "#{package.importdir} is not a hg repository"
53
53
  end
54
54
  end
55
55
 
@@ -61,9 +61,9 @@ module Autobuild
61
61
  end
62
62
  validate_importdir(package)
63
63
  package.run(:import, Autobuild.tool('hg'), 'pull',
64
- repository, retry: true, working_directory: package.importdir)
64
+ repository, retry: true, working_directory: package.importdir)
65
65
  package.run(:import, Autobuild.tool('hg'), 'update',
66
- branch, working_directory: package.importdir)
66
+ branch, working_directory: package.importdir)
67
67
  true # no easy to know if package was updated, keep previous behavior
68
68
  end
69
69
 
@@ -72,7 +72,7 @@ module Autobuild
72
72
  FileUtils.mkdir_p(base_dir) unless File.directory?(base_dir)
73
73
 
74
74
  package.run(:import, Autobuild.tool('hg'), 'clone',
75
- '-u', branch, repository, package.importdir, retry: true)
75
+ '-u', branch, repository, package.importdir, retry: true)
76
76
  end
77
77
  end
78
78
 
@@ -14,9 +14,11 @@ module Autobuild
14
14
  # Autobuild.programs['svn'] = 'my_svn_tool'
15
15
  def initialize(svnroot, options = {})
16
16
  svnroot = [*svnroot].join("/")
17
- svnopts, common = Kernel.filter_options options,
17
+ svnopts, common = Kernel.filter_options(
18
+ options,
18
19
  :svnup => [], :svnco => [], :revision => nil,
19
20
  :repository_id => "svn:#{svnroot}"
21
+ )
20
22
  common[:repository_id] = svnopts.delete(:repository_id)
21
23
  relocate(svnroot, svnopts)
22
24
  super(common.merge(repository_id: svnopts[:repository_id]))
@@ -67,7 +69,7 @@ module Autobuild
67
69
  revision = svninfo.grep(/^Revision: /).first
68
70
  unless revision
69
71
  raise ConfigException.new(package, 'import'),
70
- "cannot get SVN information for #{package.importdir}"
72
+ "cannot get SVN information for #{package.importdir}"
71
73
  end
72
74
  revision =~ /Revision: (\d+)/
73
75
  Integer($1)
@@ -79,7 +81,9 @@ module Autobuild
79
81
  # @return [String]
80
82
  # @raises (see svn_info)
81
83
  def vcs_fingerprint(package)
82
- Digest::SHA1.hexdigest(svn_info(package).grep(/^(URL|Revision):/).sort.join("\n"))
84
+ Digest::SHA1.hexdigest(
85
+ svn_info(package).grep(/^(URL|Revision):/).sort.join("\n")
86
+ )
83
87
  end
84
88
 
85
89
  # Returns the URL of the remote SVN repository
@@ -93,7 +97,7 @@ module Autobuild
93
97
  url = svninfo.grep(/^URL: /).first
94
98
  unless url
95
99
  raise ConfigException.new(package, 'import'),
96
- "cannot get SVN information for #{package.importdir}"
100
+ "cannot get SVN information for #{package.importdir}"
97
101
  end
98
102
  url.chomp =~ /URL: (.+)/
99
103
  $1
@@ -165,8 +169,9 @@ module Autobuild
165
169
  Hash.new
166
170
  end
167
171
 
168
- options, other_options = Kernel.filter_options options,
169
- working_directory: package.importdir, retry: true
172
+ options, other_options = Kernel.filter_options(
173
+ options, working_directory: package.importdir, retry: true
174
+ )
170
175
  options = options.merge(other_options)
171
176
  package.run(:import, Autobuild.tool(:svn), *args, options, &block)
172
177
  end
@@ -197,13 +202,15 @@ module Autobuild
197
202
  # Try svn upgrade and info again
198
203
  run_svn(package, 'upgrade', retry: false)
199
204
  svninfo = run_svn(package, 'info')
200
- else raise
205
+ else
206
+ raise
201
207
  end
202
208
  end
203
209
 
204
210
  unless svninfo.grep(/is not a working copy/).empty?
205
211
  raise ConfigException.new(package, 'import'),
206
- "#{package.importdir} does not appear to be a Subversion working copy"
212
+ "#{package.importdir} does not appear to be a "\
213
+ "Subversion working copy"
207
214
  end
208
215
  svninfo
209
216
  ensure
@@ -241,8 +248,8 @@ module Autobuild
241
248
 
242
249
  def checkout(package, _options = Hash.new) # :nodoc:
243
250
  run_svn(package, 'co', "--non-interactive", *@options_co,
244
- svnroot, package.importdir,
245
- working_directory: nil)
251
+ svnroot, package.importdir,
252
+ working_directory: nil)
246
253
  end
247
254
  end
248
255