autobuild 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +30 -0
- data/.rubocop.yml +14 -7
- data/autobuild.gemspec +1 -1
- data/bin/autobuild +1 -1
- data/lib/autobuild/build_logfile.rb +1 -2
- data/lib/autobuild/config.rb +5 -5
- data/lib/autobuild/environment.rb +28 -45
- data/lib/autobuild/exceptions.rb +11 -5
- data/lib/autobuild/import/archive.rb +31 -22
- data/lib/autobuild/import/cvs.rb +6 -6
- data/lib/autobuild/import/darcs.rb +4 -4
- data/lib/autobuild/import/git-lfs.rb +4 -4
- data/lib/autobuild/import/git.rb +139 -66
- data/lib/autobuild/import/hg.rb +7 -7
- data/lib/autobuild/import/svn.rb +15 -9
- data/lib/autobuild/importer.rb +33 -37
- data/lib/autobuild/mail_reporter.rb +5 -2
- data/lib/autobuild/package.rb +14 -12
- data/lib/autobuild/packages/autotools.rb +3 -8
- data/lib/autobuild/packages/cmake.rb +11 -8
- data/lib/autobuild/packages/dummy.rb +0 -4
- data/lib/autobuild/packages/gnumake.rb +1 -1
- data/lib/autobuild/packages/orogen.rb +11 -4
- data/lib/autobuild/packages/pkgconfig.rb +2 -2
- data/lib/autobuild/packages/python.rb +1 -2
- data/lib/autobuild/packages/ruby.rb +5 -5
- data/lib/autobuild/parallel.rb +7 -16
- data/lib/autobuild/pkgconfig.rb +1 -0
- data/lib/autobuild/progress_display.rb +5 -9
- data/lib/autobuild/rake_task_extension.rb +6 -0
- data/lib/autobuild/reporting.rb +7 -7
- data/lib/autobuild/subcommand.rb +24 -23
- data/lib/autobuild/timestamps.rb +3 -3
- data/lib/autobuild/utility.rb +3 -3
- data/lib/autobuild/version.rb +1 -1
- data/lib/autobuild.rb +0 -3
- metadata +5 -4
- data/.travis.yml +0 -21
data/lib/autobuild/import/cvs.rb
CHANGED
@@ -10,7 +10,7 @@ module Autobuild
|
|
10
10
|
# Autobuild.programs['cvs'] = 'my_cvs_tool'
|
11
11
|
def initialize(root_name, options = {})
|
12
12
|
cvsopts, common = Kernel.filter_options options,
|
13
|
-
|
13
|
+
module: nil, cvsup: '-dP', cvsco: '-P'
|
14
14
|
@root = root_name
|
15
15
|
@module = cvsopts[:module]
|
16
16
|
raise ArgumentError, "no module given" unless @module
|
@@ -41,7 +41,7 @@ module Autobuild
|
|
41
41
|
|
42
42
|
unless File.exist?("#{package.srcdir}/CVS/Root")
|
43
43
|
raise ConfigException.new(package, 'import'),
|
44
|
-
|
44
|
+
"#{package.srcdir} is not a CVS working copy"
|
45
45
|
end
|
46
46
|
|
47
47
|
root = File.open("#{package.srcdir}/CVS/Root", &:read).chomp
|
@@ -56,8 +56,8 @@ module Autobuild
|
|
56
56
|
|
57
57
|
if root != expected_root || mod != @module
|
58
58
|
raise ConfigException.new(package, 'import'),
|
59
|
-
|
60
|
-
|
59
|
+
"checkout in #{package.srcdir} is from #{root}:#{mod}, "\
|
60
|
+
"was expecting #{expected_root}:#{@module}"
|
61
61
|
end
|
62
62
|
package.run(:import, Autobuild.tool(:cvs), 'up', *@options_up,
|
63
63
|
retry: true, working_directory: package.importdir)
|
@@ -72,8 +72,8 @@ module Autobuild
|
|
72
72
|
|
73
73
|
FileUtils.mkdir_p(head) unless File.directory?(head)
|
74
74
|
package.run(:import, Autobuild.tool(:cvs), '-d', cvsroot, 'co',
|
75
|
-
|
76
|
-
|
75
|
+
'-d', tail, *@options_co, modulename,
|
76
|
+
retry: true, working_directory: head)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -28,12 +28,12 @@ module Autobuild
|
|
28
28
|
end
|
29
29
|
unless File.directory?(File.join(package.srcdir, '_darcs'))
|
30
30
|
raise ConfigException.new(package, 'import'),
|
31
|
-
|
31
|
+
"#{package.srcdir} is not a Darcs repository"
|
32
32
|
end
|
33
33
|
|
34
34
|
package.run(:import, @program, 'pull', '--all',
|
35
|
-
|
36
|
-
|
35
|
+
"--repodir=#{package.srcdir}", '--set-scripts-executable',
|
36
|
+
@source, *@pull, retry: true)
|
37
37
|
true # no easy to know if package was updated, keep previous behavior
|
38
38
|
end
|
39
39
|
|
@@ -42,7 +42,7 @@ module Autobuild
|
|
42
42
|
FileUtils.mkdir_p(basedir) unless File.directory?(basedir)
|
43
43
|
|
44
44
|
package.run(:import, @program, 'get', '--set-scripts-executable',
|
45
|
-
|
45
|
+
@source, package.srcdir, *@get, retry: true)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -10,26 +10,26 @@ module Autobuild
|
|
10
10
|
if includes.empty?
|
11
11
|
begin
|
12
12
|
importer.run_git_bare(package, 'config', '--local',
|
13
|
-
|
13
|
+
'--unset', 'lfs.fetchinclude')
|
14
14
|
rescue SubcommandFailed => e
|
15
15
|
raise if e.status != 5
|
16
16
|
end
|
17
17
|
else
|
18
18
|
importer.run_git_bare(package, 'config', '--local',
|
19
|
-
|
19
|
+
'lfs.fetchinclude', includes)
|
20
20
|
end
|
21
21
|
|
22
22
|
excludes = importer.options.fetch(:lfs_exclude, '')
|
23
23
|
if excludes.empty?
|
24
24
|
begin
|
25
25
|
importer.run_git_bare(package, 'config', '--local',
|
26
|
-
|
26
|
+
'--unset', 'lfs.fetchexclude')
|
27
27
|
rescue SubcommandFailed => e
|
28
28
|
raise if e.status != 5
|
29
29
|
end
|
30
30
|
else
|
31
31
|
importer.run_git_bare(package, 'config', '--local',
|
32
|
-
|
32
|
+
'lfs.fetchexclude', excludes)
|
33
33
|
end
|
34
34
|
|
35
35
|
if importer.options[:lfs] != false
|
data/lib/autobuild/import/git.rb
CHANGED
@@ -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
|
#
|
@@ -54,7 +57,7 @@ module Autobuild
|
|
54
57
|
def self.version
|
55
58
|
version = Subprocess.run('git', 'setup', Autobuild.tool(:git), '--version').
|
56
59
|
first
|
57
|
-
if version =~ /^git version (\d[\d
|
60
|
+
if version =~ /^git version (\d[\d.]+)/
|
58
61
|
$1.split(".").map { |i| Integer(i) }
|
59
62
|
else
|
60
63
|
raise ArgumentError, "cannot parse git version string #{version}, "\
|
@@ -139,16 +142,16 @@ module Autobuild
|
|
139
142
|
end
|
140
143
|
|
141
144
|
gitopts, common = Kernel.filter_options options,
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
145
|
+
push_to: nil,
|
146
|
+
branch: nil,
|
147
|
+
local_branch: nil,
|
148
|
+
remote_branch: nil,
|
149
|
+
tag: nil,
|
150
|
+
commit: nil,
|
151
|
+
repository_id: nil,
|
152
|
+
source_id: nil,
|
153
|
+
with_submodules: false,
|
154
|
+
single_branch: false
|
152
155
|
if gitopts[:branch] && branch
|
153
156
|
raise ConfigException, "git branch specified with both the option hash "\
|
154
157
|
"and the explicit parameter"
|
@@ -293,6 +296,66 @@ module Autobuild
|
|
293
296
|
git_dir(package, true)
|
294
297
|
end
|
295
298
|
|
299
|
+
# Return the remote head branch from local copy if exists, if not return nil
|
300
|
+
#
|
301
|
+
# @param [Package] package
|
302
|
+
def try_resolve_remote_head_from_local(package)
|
303
|
+
ls_local_string = run_git(package, 'symbolic-ref',
|
304
|
+
"refs/remotes/#{@remote_name}/HEAD").first.strip
|
305
|
+
local_remote_head = ls_local_string.match("refs/remotes/#{@remote_name}/(.*)")
|
306
|
+
local_remote_head ? local_remote_head[1] : nil
|
307
|
+
rescue Autobuild::SubcommandFailed # rubocop:disable Lint/SuppressedException
|
308
|
+
end
|
309
|
+
|
310
|
+
# Return the remote head branch from server if exists, if not return 'master'
|
311
|
+
#
|
312
|
+
# @param [Package] package
|
313
|
+
def try_resolve_remote_head_from_server(package)
|
314
|
+
ls_remote_string = package.run(
|
315
|
+
:import,
|
316
|
+
Autobuild.tool('git'), 'ls-remote', '--symref', repository
|
317
|
+
).first.strip
|
318
|
+
server_remote_head =
|
319
|
+
ls_remote_string.match("ref:[^A-z]refs/heads/(.*)[^A-z]HEAD")
|
320
|
+
server_remote_head ? server_remote_head[1] : 'master'
|
321
|
+
end
|
322
|
+
|
323
|
+
# Return default local branch if exists, if not return the default remote branch
|
324
|
+
#
|
325
|
+
# @param [Package] package
|
326
|
+
def resolve_remote_head(package, only_local: false)
|
327
|
+
try_resolve_remote_head_from_local(package) ||
|
328
|
+
(!only_local && try_resolve_remote_head_from_server(package))
|
329
|
+
end
|
330
|
+
|
331
|
+
# Whether both the local and remote branches are known
|
332
|
+
#
|
333
|
+
# See documentation of {#resolve_all_branches}
|
334
|
+
def has_all_branches?
|
335
|
+
remote_branch && local_branch
|
336
|
+
end
|
337
|
+
|
338
|
+
# Resolve branches based on the remote's HEAD
|
339
|
+
#
|
340
|
+
# Since GitHub (and others) decided to change the name of the "default"
|
341
|
+
# branch, we can't assume that master is ... well ... master.
|
342
|
+
#
|
343
|
+
# For this reason, a Git importer does not have a built-in default.
|
344
|
+
# If the branch(es) are not provided explicitly, the importer will
|
345
|
+
# call this method to guess the name of the default branch instead.
|
346
|
+
#
|
347
|
+
# Call {#has_all_branches?} to determine whether it is necessary
|
348
|
+
def resolve_all_branches(package, only_local: false)
|
349
|
+
default_branch = resolve_remote_head(package, only_local: only_local)
|
350
|
+
unless default_branch
|
351
|
+
raise NetworkAccessNeeded,
|
352
|
+
"determining the remote branch would require access to "\
|
353
|
+
"the network, and only_local is true"
|
354
|
+
end
|
355
|
+
|
356
|
+
relocate(repository, default_branch: default_branch)
|
357
|
+
end
|
358
|
+
|
296
359
|
# @api private
|
297
360
|
#
|
298
361
|
# Resolves the git directory associated with path, and tells whether it
|
@@ -366,12 +429,12 @@ module Autobuild
|
|
366
429
|
def self.validate_git_dir(package, require_working_copy, _dir, style)
|
367
430
|
if !style
|
368
431
|
raise ConfigException.new(package, 'import', retry: false),
|
369
|
-
|
370
|
-
|
432
|
+
"while importing #{package.name}, #{package.importdir} "\
|
433
|
+
"does not point to a git repository"
|
371
434
|
elsif require_working_copy && (style == :bare)
|
372
435
|
raise ConfigException.new(package, 'import', retry: false),
|
373
|
-
|
374
|
-
|
436
|
+
"while importing #{package.name}, #{package.importdir} "\
|
437
|
+
"points to a bare git repository but a working copy was required"
|
375
438
|
end
|
376
439
|
end
|
377
440
|
|
@@ -477,21 +540,24 @@ module Autobuild
|
|
477
540
|
#
|
478
541
|
# Set a remote up in the repositorie's configuration
|
479
542
|
def setup_remote(package, remote_name, repository, push_to = repository)
|
543
|
+
resolve_all_branches(package, only_local: true) unless has_all_branches?
|
544
|
+
|
480
545
|
run_git_bare(package, 'config', '--replace-all',
|
481
|
-
|
546
|
+
"remote.#{remote_name}.url", repository)
|
482
547
|
run_git_bare(package, 'config', '--replace-all',
|
483
|
-
|
548
|
+
"remote.#{remote_name}.pushurl", push_to || repository)
|
484
549
|
run_git_bare(package, 'config', '--replace-all',
|
485
|
-
|
486
|
-
|
550
|
+
"remote.#{remote_name}.fetch",
|
551
|
+
"+refs/heads/*:refs/remotes/#{remote_name}/*")
|
487
552
|
|
488
553
|
if remote_branch && local_branch
|
554
|
+
remote_ref = remote_branch_to_ref(remote_branch)
|
489
555
|
run_git_bare(package, 'config', '--replace-all',
|
490
|
-
|
491
|
-
|
556
|
+
"remote.#{remote_name}.push",
|
557
|
+
"refs/heads/#{local_branch}:#{remote_ref}")
|
492
558
|
else
|
493
559
|
run_git_bare(package, 'config', '--replace-all',
|
494
|
-
|
560
|
+
"remote.#{remote_name}.push", "refs/heads/*:refs/heads/*")
|
495
561
|
end
|
496
562
|
end
|
497
563
|
|
@@ -517,16 +583,17 @@ module Autobuild
|
|
517
583
|
|
518
584
|
if local_branch
|
519
585
|
run_git_bare(package, 'config', '--replace-all',
|
520
|
-
|
586
|
+
"branch.#{local_branch}.remote", remote_name)
|
521
587
|
run_git_bare(package, 'config', '--replace-all',
|
522
|
-
|
588
|
+
"branch.#{local_branch}.merge",
|
589
|
+
remote_branch_to_ref(local_branch))
|
523
590
|
end
|
524
591
|
end
|
525
592
|
|
526
593
|
# Resolve a commit ref to a tag or commit ID
|
527
594
|
def describe_rev(package, rev)
|
528
595
|
tag = run_git_bare(package, 'describe',
|
529
|
-
|
596
|
+
'--tags', '--exact-match', rev).first.strip
|
530
597
|
[true, tag.encode('UTF-8')]
|
531
598
|
rescue Autobuild::SubcommandFailed
|
532
599
|
commit = rev_parse(package, rev)
|
@@ -584,7 +651,7 @@ module Autobuild
|
|
584
651
|
refspec.zip(fetched_commits).each do |spec, commit_id|
|
585
652
|
if spec =~ %r{^refs/heads/(.*)$}
|
586
653
|
run_git_bare(package, 'update-ref', "-m", "updated by autobuild",
|
587
|
-
|
654
|
+
"refs/remotes/#{remote_name}/#{$1}", commit_id)
|
588
655
|
end
|
589
656
|
end
|
590
657
|
|
@@ -641,7 +708,7 @@ module Autobuild
|
|
641
708
|
run_git_bare(package, 'show-ref', '-s', refspec).first.strip
|
642
709
|
rescue SubcommandFailed
|
643
710
|
raise PackageException.new(package, "import"),
|
644
|
-
|
711
|
+
"cannot resolve #{refspec}"
|
645
712
|
end
|
646
713
|
else
|
647
714
|
refspec =
|
@@ -650,7 +717,7 @@ module Autobuild
|
|
650
717
|
remote_branch_to_ref(remote_branch)
|
651
718
|
begin fetch_remote(package, refspec: refspec)
|
652
719
|
rescue Exception => e
|
653
|
-
|
720
|
+
fallback(e, package, :status, package, only_local)
|
654
721
|
end
|
655
722
|
end
|
656
723
|
end
|
@@ -666,6 +733,8 @@ module Autobuild
|
|
666
733
|
end
|
667
734
|
|
668
735
|
validate_importdir(package)
|
736
|
+
resolve_all_branches(package, only_local: only_local) unless has_all_branches?
|
737
|
+
|
669
738
|
_pinned_state, target_commit, = determine_target_state(
|
670
739
|
package, only_local: only_local)
|
671
740
|
|
@@ -696,7 +765,7 @@ module Autobuild
|
|
696
765
|
|
697
766
|
def has_branch?(package, branch_name)
|
698
767
|
run_git_bare(package, 'show-ref', '-q', '--verify',
|
699
|
-
|
768
|
+
remote_branch_to_ref(branch_name))
|
700
769
|
true
|
701
770
|
rescue SubcommandFailed => e
|
702
771
|
if e.status == 1
|
@@ -706,7 +775,7 @@ module Autobuild
|
|
706
775
|
end
|
707
776
|
|
708
777
|
def has_local_branch?(package)
|
709
|
-
has_branch?(package, local_branch)
|
778
|
+
has_branch?(package, local_branch) if local_branch
|
710
779
|
end
|
711
780
|
|
712
781
|
def detached_head?(package)
|
@@ -714,6 +783,8 @@ module Autobuild
|
|
714
783
|
end
|
715
784
|
|
716
785
|
private def remote_branch_to_ref(branch)
|
786
|
+
return unless branch
|
787
|
+
|
717
788
|
if branch.start_with?("refs/")
|
718
789
|
branch
|
719
790
|
else
|
@@ -750,9 +821,7 @@ module Autobuild
|
|
750
821
|
#
|
751
822
|
# This is the value returned by {Git#status}
|
752
823
|
class Status < Importer::Status
|
753
|
-
attr_reader :fetch_commit
|
754
|
-
attr_reader :head_commit
|
755
|
-
attr_reader :common_commit
|
824
|
+
attr_reader :fetch_commit, :head_commit, :common_commit
|
756
825
|
|
757
826
|
def initialize(package, status, remote_commit, local_commit, common_commit)
|
758
827
|
super()
|
@@ -797,8 +866,8 @@ module Autobuild
|
|
797
866
|
run_git_bare(package, 'rev-parse', '-q', '--verify', name).first
|
798
867
|
rescue Autobuild::SubcommandFailed
|
799
868
|
raise PackageException.new(package, 'import'),
|
800
|
-
|
801
|
-
|
869
|
+
"failed to resolve #{name}. "\
|
870
|
+
"Are you sure this commit, branch or tag exists ?"
|
802
871
|
end
|
803
872
|
|
804
873
|
# Returns the file's conents at a certain commit
|
@@ -811,7 +880,7 @@ module Autobuild
|
|
811
880
|
run_git_bare(package, 'show', "#{commit}:#{path}").join("\n")
|
812
881
|
rescue Autobuild::SubcommandFailed
|
813
882
|
raise PackageException.new(package, 'import'),
|
814
|
-
|
883
|
+
"failed to either resolve commit #{commit} or file #{path}"
|
815
884
|
end
|
816
885
|
|
817
886
|
# Tests whether a commit is already present in a given history
|
@@ -845,7 +914,7 @@ module Autobuild
|
|
845
914
|
def describe_commit_on_remote(package, rev = 'HEAD', options = Hash.new)
|
846
915
|
rev = rev.to_str
|
847
916
|
options = Kernel.validate_options options,
|
848
|
-
|
917
|
+
tags: true
|
849
918
|
|
850
919
|
commit_id = rev_parse(package, rev)
|
851
920
|
|
@@ -875,15 +944,13 @@ module Autobuild
|
|
875
944
|
end
|
876
945
|
|
877
946
|
remote_refs.delete_if do |rev_name, rev_id|
|
878
|
-
begin
|
879
947
|
if commit_present_in?(package, commit_id, rev_id)
|
880
948
|
return rev_name
|
881
949
|
else
|
882
950
|
true
|
883
951
|
end
|
884
|
-
|
952
|
+
rescue PackageException
|
885
953
|
false
|
886
|
-
end
|
887
954
|
end
|
888
955
|
|
889
956
|
unless remote_refs.empty?
|
@@ -909,7 +976,7 @@ module Autobuild
|
|
909
976
|
def merge_status(package, fetch_commit, reference_commit = "HEAD")
|
910
977
|
begin
|
911
978
|
common_commit = run_git_bare(package, 'merge-base',
|
912
|
-
|
979
|
+
reference_commit, fetch_commit).first.strip
|
913
980
|
rescue Exception
|
914
981
|
raise PackageException.new(package, 'import'), "failed to find "\
|
915
982
|
"the merge-base between #{reference_commit} and #{fetch_commit}. "\
|
@@ -942,7 +1009,7 @@ module Autobuild
|
|
942
1009
|
# @return [void]
|
943
1010
|
def update_alternates(package)
|
944
1011
|
alternates_path = File.join(git_dir(package, false),
|
945
|
-
|
1012
|
+
'objects', 'info', 'alternates')
|
946
1013
|
current_alternates =
|
947
1014
|
if File.file?(alternates_path)
|
948
1015
|
File.readlines(alternates_path)
|
@@ -1007,18 +1074,18 @@ module Autobuild
|
|
1007
1074
|
# changes
|
1008
1075
|
unless commit_present_in?(package, current_head, fetch_commit)
|
1009
1076
|
raise ImporterCannotReset.new(package, 'import'),
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1077
|
+
"branch #{local_branch} of #{package.name} contains"\
|
1078
|
+
" commits that do not seem to be present on the branch"\
|
1079
|
+
" #{remote_branch} of the remote repository. I can't"\
|
1080
|
+
" go on as it could make you lose some stuff. Update"\
|
1081
|
+
" the remote branch in your overrides, push your"\
|
1082
|
+
" changes or reset to the remote commit manually"\
|
1083
|
+
" before trying again"
|
1017
1084
|
end
|
1018
1085
|
end
|
1019
1086
|
|
1020
1087
|
package.message format(" %%s: resetting branch %<branch>s to %<commit>s",
|
1021
|
-
|
1088
|
+
branch: local_branch, commit: target_commit)
|
1022
1089
|
# I don't use a reset --hard here as it would add even more
|
1023
1090
|
# restrictions on when we can do the operation (as we would refuse
|
1024
1091
|
# doing it if there are local changes). The checkout creates a
|
@@ -1029,7 +1096,7 @@ module Autobuild
|
|
1029
1096
|
begin
|
1030
1097
|
run_git(package, 'checkout', target_commit)
|
1031
1098
|
run_git(package, 'update-ref', "refs/heads/#{local_branch}",
|
1032
|
-
|
1099
|
+
resolved_target_commit)
|
1033
1100
|
run_git(package, 'symbolic-ref', "HEAD", "refs/heads/#{local_branch}")
|
1034
1101
|
rescue ::Exception
|
1035
1102
|
run_git(package, 'symbolic-ref', "HEAD", target_commit)
|
@@ -1065,6 +1132,9 @@ module Autobuild
|
|
1065
1132
|
# @option (see Package#update)
|
1066
1133
|
def update(package, options = Hash.new)
|
1067
1134
|
validate_importdir(package)
|
1135
|
+
|
1136
|
+
resolve_all_branches(package) unless has_all_branches?
|
1137
|
+
|
1068
1138
|
only_local = options.fetch(:only_local, false)
|
1069
1139
|
reset = options.fetch(:reset, false)
|
1070
1140
|
|
@@ -1084,20 +1154,21 @@ module Autobuild
|
|
1084
1154
|
end
|
1085
1155
|
|
1086
1156
|
unless pin_is_uptodate
|
1087
|
-
fetch_commit ||= current_remote_commit(
|
1088
|
-
only_local: only_local,
|
1089
|
-
|
1157
|
+
fetch_commit ||= current_remote_commit(
|
1158
|
+
package, only_local: only_local,
|
1159
|
+
refspec: [remote_branch_to_ref(remote_branch), tag]
|
1160
|
+
)
|
1090
1161
|
did_update =
|
1091
1162
|
if reset
|
1092
1163
|
reset_head_to_commit(package, target_commit, fetch_commit,
|
1093
|
-
|
1164
|
+
force: (reset == :force))
|
1094
1165
|
else
|
1095
1166
|
merge_if_simple(package, target_commit)
|
1096
1167
|
end
|
1097
1168
|
end
|
1098
1169
|
|
1099
1170
|
if !only_local && with_submodules?
|
1100
|
-
run_git(package, "submodule", "update", '--init')
|
1171
|
+
run_git(package, "submodule", "update", '--init', '--recursive')
|
1101
1172
|
did_update = true
|
1102
1173
|
end
|
1103
1174
|
|
@@ -1107,12 +1178,12 @@ module Autobuild
|
|
1107
1178
|
private def ensure_on_local_branch(package, target_commit)
|
1108
1179
|
if !has_local_branch?(package)
|
1109
1180
|
package.message format("%%s: checking out branch %<branch>s",
|
1110
|
-
|
1181
|
+
branch: local_branch)
|
1111
1182
|
run_git(package, 'checkout', '-b', local_branch, target_commit)
|
1112
1183
|
true
|
1113
1184
|
elsif !on_local_branch?(package)
|
1114
1185
|
package.message format("%%s: switching to branch %<branch>s",
|
1115
|
-
|
1186
|
+
branch: local_branch)
|
1116
1187
|
run_git(package, 'checkout', local_branch)
|
1117
1188
|
true
|
1118
1189
|
else
|
@@ -1195,28 +1266,30 @@ module Autobuild
|
|
1195
1266
|
clone_options << "--config=#{key}=#{value}"
|
1196
1267
|
end
|
1197
1268
|
package.run(:import,
|
1198
|
-
|
1199
|
-
|
1269
|
+
Autobuild.tool('git'), 'clone', '-o', remote_name, *clone_options,
|
1270
|
+
repository, package.importdir, retry: true)
|
1200
1271
|
|
1201
1272
|
update_remotes_configuration(package)
|
1202
1273
|
update(package, only_local: !remote_branch.start_with?("refs/"),
|
1203
1274
|
reset: :force)
|
1204
|
-
|
1275
|
+
if with_submodules?
|
1276
|
+
run_git(package, "submodule", "update", '--init', '--recursive')
|
1277
|
+
end
|
1205
1278
|
end
|
1206
1279
|
|
1207
1280
|
# Changes the repository this importer is pointing to
|
1208
1281
|
def relocate(repository, options = Hash.new)
|
1209
|
-
options =
|
1282
|
+
options = options.transform_keys(&:to_sym)
|
1210
1283
|
|
1211
1284
|
local_branch =
|
1212
1285
|
options[:local_branch] || options[:branch] ||
|
1213
|
-
self.local_branch ||
|
1286
|
+
self.local_branch || options[:default_branch] || nil
|
1214
1287
|
remote_branch =
|
1215
1288
|
options[:remote_branch] || options[:branch] ||
|
1216
|
-
self.remote_branch ||
|
1217
|
-
if local_branch
|
1289
|
+
self.remote_branch || options[:default_branch] || nil
|
1290
|
+
if local_branch&.start_with?("refs/")
|
1218
1291
|
raise ArgumentError, "you cannot provide a full ref for"\
|
1219
|
-
|
1292
|
+
" the local branch, only for the remote branch"
|
1220
1293
|
end
|
1221
1294
|
|
1222
1295
|
@push_to = options[:push_to] || @push_to
|