diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2013-09-28 10:15:21 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2013-09-28 10:19:01 +0200 |
commit | 0481e076f3cb4010894324cac71e947c6637805a (patch) | |
tree | e178f31417296d70f83590654999e2444280edad /sync-all | |
parent | 8634935af68886d240ad22e23c2789a707f241f4 (diff) | |
download | haskell-0481e076f3cb4010894324cac71e947c6637805a.tar.gz |
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 <hvr@gnu.org>
Diffstat (limited to 'sync-all')
-rwxr-xr-x | sync-all | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -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); } |