[Bps-public-commit] git-sync branch, master, updated. 5ba90333654c4b9242f91f557528a5e6ecae1de8

Alex M Vandiver alexmv at bestpractical.com
Fri Jan 8 01:03:19 EST 2010


The branch, master has been updated
       via  5ba90333654c4b9242f91f557528a5e6ecae1de8 (commit)
      from  fa66b910912597a3aeef36dd0993b3bbd353d4cb (commit)

Summary of changes:
 git-sync |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 5ba90333654c4b9242f91f557528a5e6ecae1de8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Jan 8 01:01:43 2010 -0500

    Allow '*' wildcard in "path" configuration
    
    If a user only wishes to clone a subset of the repositories on a
    remote host, allow them to specify a path of "/git/foo-*", which only
    matches repositories starting with "foo-".

diff --git a/git-sync b/git-sync
index 45c9de6..d472c9f 100755
--- a/git-sync
+++ b/git-sync
@@ -95,6 +95,10 @@ C<hostname:/path>.
             # under this directory
             into = /home/alexmv/example.com
 
+The If the path includes a '*', it is treated as a list of remote
+repository paths.  Otherwise, all subdirectories of the path which are
+git repositories are acted on.
+
 Note that local categories can be overlapped with other types; the
 following configuration clones and updates all of alexmv's github
 repositories, and also updates any other repositories it happens to
@@ -307,10 +311,12 @@ sub sync_all_remote {
 
     my @paths = ref $config{path} ? @{$config{path}} : ($config{path});
     for my $path (@paths) {
-        my @list = `ssh $config{host} ls $path`;
+        $path .= '/*' unless $path =~ /\*/;
+        my @list = `ssh $config{host} ls -d $path`;
         print colored("  Listing returned ".($? >> 8).", skipping!\n", "bold red") and next if $?;
-        for my $reponame (@list) {
-            $reponame =~ s/(\.git)?\n?$//;
+        for my $repopath (@list) {
+            chomp $repopath;
+            my ($reponame) = $repopath =~ m{(?:^|/)([^/]*?)(?:\.git)?$};
             my $into = "$config{into}/$reponame";
 
             printf "  %-40s ", $reponame;
@@ -318,16 +324,16 @@ sub sync_all_remote {
             if (-e $into) {
                 update($into, 1);
             } else {
-                `ssh $config{host} [ -e $path/${reponame}.git/config ]`;
+                `ssh $config{host} [ -e $repopath/config ]`;
                 print $verbose ? colored("[ Not a git repository ]\n", "dark") : "\r" and next
                     if $?;
 
-                my ($ignore) = `ssh $config{host} git config --bool -f $path/${reponame}.git/config sync.ignore`;
+                my ($ignore) = `ssh $config{host} git config --bool -f $repopath/config sync.ignore`;
                 chomp $ignore if defined $ignore;
                 print $verbose ? colored("[ sync.ignore set ]\n", "dark") : "\r" and next
                     if defined $ignore and $ignore eq 'true';
 
-                clone($into => "$config{host}:$path/$reponame", $config{email});
+                clone($into => "$config{host}:$repopath", $config{email});
             }
         }
     }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list