diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-04-05 11:02:40 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-04-05 12:20:06 +0100 |
commit | db485571de4216b379fad54b377fa970d204bcae (patch) | |
tree | 606932a2c57304def3dea2b9c64ff452ea61ed21 /sync-all | |
parent | 3a50b1f6cb7d4455c0df851b213a51e67bb16c7f (diff) | |
download | haskell-db485571de4216b379fad54b377fa970d204bcae.tar.gz |
Add "remote add" and "remote rm" commands
To add and delete remote branches from all subrepos. e.g.
./sync-all -r ~/git/ghc-working remote add working
./sync-all remote rm working
Diffstat (limited to 'sync-all')
-rwxr-xr-x | sync-all | 111 |
1 files changed, 69 insertions, 42 deletions
@@ -215,6 +215,8 @@ sub scmall { my $scm; my $upstream; my $line; + my $branch_name; + my $subcommand; my $path; my $wd_before = getcwd; @@ -227,6 +229,17 @@ sub scmall { parsePackages; + if ($command =~ /^remote$/) { + if (@_ < 2) { + help(); + } + $subcommand = shift; + $branch_name = shift; + if ($subcommand ne 'add' && $subcommand ne 'rm') { + help(); + } + } + for $line (@packages) { $localpath = $$line{"localpath"}; @@ -301,7 +314,6 @@ sub scmall { } elsif ($command =~ /^set-push$/) { @scm_args = ("remote", "set-url", "--push", "origin", $path); - print "foo\n", @scm_args; } elsif ($command =~ /^fetch$/) { @scm_args = ("fetch", "origin"); @@ -309,6 +321,13 @@ sub scmall { elsif ($command =~ /^new$/) { @scm_args = ("log", "origin.."); } + elsif ($command =~ /^remote$/) { + if ($subcommand eq 'add') { + @scm_args = ("remote", "add", $branch_name, $path); + } elsif ($subcommand eq 'rm') { + @scm_args = ("remote", "rm", $branch_name); + } + } else { die "Unknown command: $command"; } @@ -341,6 +360,54 @@ sub scmall { } } + +sub help() +{ + # Get the built in help + my $help = <<END; +What do you want to do? +Supported commands: + + * whatsnew + * push + * pull + * get, with options: + * --<package-tag> + * --complete + * --partial + * fetch + * send + * set-origin + * set-push + * new + * remote add <branch-name> + * remote rm <branch-name> + +Available package-tags are: +END + + # Collect all the tags in the packages file + my %available_tags; + open IN, "< packages" or die "Can't open packages file"; + while (<IN>) { + chomp; + if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)/) { + if (defined($2) && $2 ne "-") { + $available_tags{$2} = 1; + } + } + elsif (! /^(#.*)?$/) { + die "Bad line: $_"; + } + } + close IN; + + # Show those tags and the help text + my @available_tags = keys %available_tags; + print "$help@available_tags\n"; + exit 1; +} + sub main { if (! -d ".git" || ! -d "compiler") { die "error: sync-all must be run from the top level of the ghc tree." @@ -389,47 +456,7 @@ sub main { } if ($#_ eq -1) { - # Get the built in help - my $help = <<END; -What do you want to do? -Supported commands: - - * whatsnew - * push - * pull - * get, with options: - * --<package-tag> - * --complete - * --partial - * fetch - * send - * set-origin - * set-push - * new - -Available package-tags are: -END - - # Collect all the tags in the packages file - my %available_tags; - open IN, "< packages" or die "Can't open packages file"; - while (<IN>) { - chomp; - if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)/) { - if (defined($2) && $2 ne "-") { - $available_tags{$2} = 1; - } - } - elsif (! /^(#.*)?$/) { - die "Bad line: $_"; - } - } - close IN; - - # Show those tags and the help text - my @available_tags = keys %available_tags; - print "$help@available_tags\n"; - exit 1; + help(); } else { # Give the command and rest of the arguments to the main loop |