Commit 0481e076 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Teach sync-all how to rewrite submodule repo urls



This applies attachment:sync-all-submodules-locally.diff from #8369

Authored-by: Nathaniel Filardo
Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
parent 8634935a
......@@ -176,6 +176,7 @@ sub getrepo {
my $repo_base;
my $checked_out_tree;
my $repo_local = 0;
if ($repo =~ /^...*:/) {
# HTTP or SSH
......@@ -206,6 +207,7 @@ sub getrepo {
}
elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
# Local filesystem, either absolute (C:/ or /) or relative (../) path
$repo_local = 1;
$repo_base = $repo;
if (-f "$repo/HEAD") {
# assume a local mirror:
......@@ -223,7 +225,7 @@ sub getrepo {
die "Couldn't work out repo";
}
return $repo_base, $checked_out_tree;
return $repo_base, $checked_out_tree, $repo_local;
}
sub gitall {
......@@ -244,7 +246,7 @@ sub gitall {
my $doing;
my $start_repo;
my ($repo_base, $checked_out_tree) = getrepo();
my ($repo_base, $checked_out_tree, $repo_local) = getrepo();
my $is_github_repo = $repo_base =~ m/(git@|git:\/\/|https:\/\/)github.com/;
......@@ -561,6 +563,22 @@ sub gitall {
unlink "resume";
}
sub gitInitSubmodules {
&git(".", "submodule", "init", @_);
my ($repo_base, $checked_out_tree, $repo_local) = getrepo();
# if we came from a local repository, grab our submodules from their
# checkouts over there, if they exist.
if ($repo_local) {
my $gitConfig = &tryReadFile(".git/config");
foreach $_ (split /^/, $gitConfig) {
if ($_ =~ /^\[submodule "(.*)"\]$/ and -e "$repo_base/$1/.git") {
&git(".", "config", "submodule.$1.url", "$repo_base/$1");
}
}
}
}
sub checkCurrentBranchIsMaster {
my $branch = `git symbolic-ref HEAD`;
$branch =~ s/refs\/heads\///;
......@@ -892,18 +910,19 @@ sub main {
my @submodule_args = grep(/^-q/,@_);
if ($command eq "get") {
&git(".", "submodule", "init", @submodule_args);
&gitInitSubmodules(@submodule_args);
}
if ($command eq "pull") {
my $gitConfig = &tryReadFile(".git/config");
if ($gitConfig !~ /submodule/) {
&git(".", "submodule", "init", @submodule_args);
&gitInitSubmodules(@submodule_args);
}
}
if ($command eq "get" or $command eq "pull") {
my $gitConfig = &tryReadFile(".git/config");
if ($gitConfig !~ /submodule/) {
&git(".", "submodule", "init", @submodule_args);
&gitInitSubmodules(@submodule_args);
}
&git(".", "submodule", "update", @submodule_args);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment