summaryrefslogtreecommitdiff
path: root/sync-all
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2014-06-17 17:27:04 +0200
committerThomas Miedema <thomasmiedema@gmail.com>2014-06-23 16:05:11 +0200
commit72fe49d88565fc1dd807a0e185a5aa6fc4989ea0 (patch)
treea264ee7381cf83d7cba2c6e61da11986672f60dd /sync-all
parent9a131dd091323602cd4ab343031a05ef131fe122 (diff)
downloadhaskell-72fe49d88565fc1dd807a0e185a5aa6fc4989ea0.tar.gz
sync-all: infer remotepath from .gitmodules file
After this commit, running `sync-all remote set-url` works properly for the haddock package: command: ./sync-all -r git://git.haskell.org remote set-url origin before: git://git.haskell.org/packages/haddock.git after: git://git.haskell.org/haddock.git By doing the `remotepath` lookup before the `$is_github_repo` check, running `sync-all remote set-url` now also works properly for submodule repos on github: command: ./sync-all -r git://github.com/ghc remote set-url origin before: git://github.com/ghc/packages/binary after: git://github.com/ghc/packages-binary * Relevant prior commits: 4f4357 "Make `sync-all remote set-url` use normalized `/packages/` urls" 34b072 "Convert haddock into a proper submodule (re #8545)" 974a97 "sync-all: Apply submodule url rewriting also to stuff in util/"
Diffstat (limited to 'sync-all')
-rwxr-xr-xsync-all32
1 files changed, 13 insertions, 19 deletions
diff --git a/sync-all b/sync-all
index 88c40dae66..e68da62393 100755
--- a/sync-all
+++ b/sync-all
@@ -315,8 +315,6 @@ sub gitall {
# Use the "remote" structure for bare git repositories
$localpath = ($bare_flag) ?
$$line{"remotepath"} : $$line{"localpath"};
- $remotepath = ($checked_out_tree) ?
- $$line{"localpath"} : $$line{"remotepath"};
if (!$started) {
if ($start_repo eq $localpath) {
@@ -335,6 +333,17 @@ sub gitall {
$repo_is_submodule = $$line{"remotepath"} eq "-";
+ if ($checked_out_tree) {
+ $remotepath = $$line{"localpath"};
+ }
+ elsif ($repo_is_submodule) {
+ $remotepath = &readgitline(".", 'config', '-f', '.gitmodules', '--get', "submodule.$localpath.url");
+ $remotepath =~ s/\.\.\///;
+ }
+ else {
+ $remotepath = $$line{"remotepath"};
+ }
+
# We can't create directories on GitHub, so we translate
# "packages/foo" into "package-foo".
if ($is_github_repo) {
@@ -457,30 +466,15 @@ sub gitall {
}
elsif ($command eq "remote") {
my @scm_args;
- my $rpath;
$ignore_failure = 1;
- if ($repo_is_submodule) {
- $rpath = "$localpath.git"; # N.B.: $localpath lacks the .git suffix
- if ($localpath =~ m!^(?:libraries|utils)/!) {
- # FIXME: This is just a simple heuristic to
- # infer the remotepath for Git submodules. A
- # proper solution would require to parse the
- # .gitmodules file to obtain the actual
- # localpath<->remotepath mapping.
- $rpath =~ s!^(?:libraries|utils)/!packages/!;
- }
- $rpath = "$repo_base/$rpath";
- } else {
- $rpath = $path;
- }
if ($subcommand eq 'add') {
- @scm_args = ("remote", "add", $branch_name, $rpath);
+ @scm_args = ("remote", "add", $branch_name, $path);
} elsif ($subcommand eq 'rm') {
@scm_args = ("remote", "rm", $branch_name);
} elsif ($subcommand eq 'set-branches') {
@scm_args = ("remote", "set-branches", $branch_name);
} elsif ($subcommand eq 'set-url') {
- @scm_args = ("remote", "set-url", $branch_name, $rpath);
+ @scm_args = ("remote", "set-url", $branch_name, $path);
}
&git($localpath, @scm_args, @args);
}