[Bps-public-commit] git-sync branch, master, updated. 0761ebd3b3b9de6e3520551250953c751e843ae3

Alex M Vandiver alexmv at bestpractical.com
Thu Dec 3 15:20:54 EST 2009


The branch, master has been updated
       via  0761ebd3b3b9de6e3520551250953c751e843ae3 (commit)
       via  e31e94549aad7c8b2ab320574d6f901fe9791a97 (commit)
      from  681e4d3d76a499cab4a3a95c1c0f37cf81d2936b (commit)

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

- Log -----------------------------------------------------------------
commit e31e94549aad7c8b2ab320574d6f901fe9791a97
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Dec 3 13:20:55 2009 -0500

    Stop all master connections at the end, in case other syncs find them useful

diff --git a/git-sync b/git-sync
index 89ac0ec..d4ee7f8 100755
--- a/git-sync
+++ b/git-sync
@@ -188,6 +188,7 @@ if (@ARGV) {
 }
 
 my %seen;
+my %masters;
 for my $name (@categories) {
     print colored("Syncing" . (length $name ? " $name" : "")."\n", "bold");
 
@@ -203,6 +204,8 @@ for my $name (@categories) {
     print " "x45,"\n";
 }
 
+stop_masters();
+
 sub sync_all_local {
     my %config = @_;
     foreach my $into ( ref $config{into} ? @{$config{into}} : $config{into} ) {
@@ -300,7 +303,7 @@ sub sync_all_remote {
             unless eval { File::Path::mkpath($config{into}) };
     }
 
-    my $pid = start_master($config{host});
+    start_master($config{host});
 
     my @paths = ref $config{path} ? @{$config{path}} : ($config{path});
     for my $path (@paths) {
@@ -328,10 +331,6 @@ sub sync_all_remote {
             }
         }
     }
-
-    # Shut down master connection
-    `ssh -O exit $config{host} 2>&1`
-        if $pid and kill 0, $pid;
 }
 
 sub start_master {
@@ -367,7 +366,29 @@ sub start_master {
 
     sleep 1 while (`ssh -O check $host 2>&1` !~ /Master running \(pid=(\d+)\)/);
     print colored( "[ Started (PID $1) ]\n", "green" );
-    return $pid;
+    $masters{$host} = $pid;
+}
+
+sub stop_masters {
+    return unless keys %masters;
+
+    print colored("Stopping SSH master connections\n", "dark");
+
+    for my $host (keys %masters) {
+        printf colored("  %-40s ", "dark"), $host;
+        if (kill 0, $masters{$host}) {
+            my $status = `ssh -O exit $host 2>&1`;
+            if ($status =~ /Exit request sent/) {
+                print colored("[ Done ]\n", "green");
+            } else {
+                $status =~ s/\r?\n$//; # chomp doesn't remove the \r
+                print colored("[ $status ]\n", "red");
+            }
+        } else {
+            print colored("[ Already stopped! ]\n", "red");
+        }
+    }
+    print "\n";
 }
 
 sub already {

commit 0761ebd3b3b9de6e3520551250953c751e843ae3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Dec 3 13:21:30 2009 -0500

    Allow local repositories to opt out of local sync, by `git config sync.ignore`

diff --git a/git-sync b/git-sync
index d4ee7f8..45c9de6 100755
--- a/git-sync
+++ b/git-sync
@@ -414,6 +414,11 @@ sub update {
         return;
     }
 
+    if ( $repo->config_bool( "sync.ignore" )) {
+        print $verbose ? colored("[ sync.ignore set ]\n", "dark") : "\r";
+        return;
+    }
+
     my $gitsvn = -e $repo->repo_path . "/svn/.metadata";
     if ($gitsvn) {
         print colored( "[ svn ] ", "dark blue" );

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



More information about the Bps-public-commit mailing list