Add 'sync-all grep'
[ghc-hetmet.git] / sync-all
index 0d0af67..bd32e46 100755 (executable)
--- a/sync-all
+++ b/sync-all
@@ -228,6 +228,8 @@ sub scmall {
 
     my ($repo_base, $checked_out_tree) = getrepo();
 
+    my $is_github_repo = $repo_base =~ m/(git@|git:\/\/|https:\/\/)github.com/;
+
     parsePackages;
 
     @args = ();
@@ -270,6 +272,12 @@ sub scmall {
             $scm        = $$line{"vcs"};
             $upstream   = $$line{"upstream"};
 
+            # We can't create directories on GitHub, so we translate
+            # "package/foo" into "package-foo".
+            if ($is_github_repo) {
+                $remotepath =~ s/\//-/;
+            }
+
             # Check the SCM is OK as early as possible
             die "Unknown SCM: $scm" if (($scm ne "darcs") and ($scm ne "git"));
 
@@ -282,7 +290,7 @@ sub scmall {
             }
 
             # Work out the arguments we should give to the SCM
-            if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
+            if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew|status)$/) {
                 @scm_args = (($scm eq "darcs" and "whatsnew")
                           or ($scm eq "git" and "status"));
                 
@@ -346,6 +354,11 @@ sub scmall {
                     @scm_args = ("remote", "set-url", $branch_name, $path);
                 }
             }
+            elsif ($command =~ /^grep$/) {
+              @scm_args = ("grep");
+              # Hack around 'git grep' failing if there are no matches
+              $ignore_failure = 1;
+            }
             else {
                 die "Unknown command: $command";
             }
@@ -399,6 +412,7 @@ Supported commands:
  * remote add <branch-name>
  * remote rm <branch-name>
  * remote set-url [--push] <branch-name>
+ * grep
 
 Available package-tags are:
 END