[Bps-public-commit] Shipwright branch, master, updated. bd2900054945352e3ea2b6a05bce398e8909ad0d

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Oct 12 19:59:31 EDT 2009


The branch, master has been updated
       via  bd2900054945352e3ea2b6a05bce398e8909ad0d (commit)
       via  99e3bbfe6ceb2238c2bd659af75b520c2f47e552 (commit)
      from  8378815a661c04707702ae65eb702faae23fd635 (commit)

Summary of changes:
 lib/Shipwright/Backend/Git.pm |   58 +++++++++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 22 deletions(-)

- Log -----------------------------------------------------------------
commit 99e3bbfe6ceb2238c2bd659af75b520c2f47e552
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 13 07:58:02 2009 +0800

    after 1.6.2, git clone an empty repo works

diff --git a/lib/Shipwright/Backend/Git.pm b/lib/Shipwright/Backend/Git.pm
index f26283b..7a64718 100644
--- a/lib/Shipwright/Backend/Git.pm
+++ b/lib/Shipwright/Backend/Git.pm
@@ -84,28 +84,45 @@ sub _init_new_git_repos {
     chdir $new_repos_dir;
     Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_GIT'}, '--bare', 'init' ] );
 
-    ### make a temporary non-bare repos to initialize the new bare
-    ### repos with, pushing from the regular repos to the bare one
-    my $dir =
-      tempdir( 'shipwright_backend_git_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
-
-    chdir $dir;
-    Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_GIT'}, 'init' ] );
-
-    # touch a file in the non-bare repos
-    my $initial_file = '.shipwright_git_initial';
-    { open my $f, '>', $initial_file or confess "$! writing $dir/$initial_file" }
+    my ($output) =
+      Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_GIT'}, '--version' ] );
+    my ($version) = $output =~ /(\d+\.\d+\.\d+)/;
+    if ( $version && $version lt '1.6.2' ) {
+
+        ### git doesn't allow to clone an empty repo before 1.6.2
+        ### make a temporary non-bare repos to initialize the new bare
+        ### repos with, pushing from the regular repos to the bare one
+        my $dir =
+          tempdir( 'shipwright_backend_git_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
+
+        chdir $dir;
+        Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_GIT'}, 'init' ] );
+
+        # touch a file in the non-bare repos
+        my $initial_file = '.shipwright_git_initial';
+        {
+            open my $f,
+              '>', $initial_file
+              or confess "$! writing $dir/$initial_file"
+        }
 
-    Shipwright::Util->run(
-        [ $ENV{'SHIPWRIGHT_GIT'}, 'add',  $initial_file ] );
-    Shipwright::Util->run(
-        [ $ENV{'SHIPWRIGHT_GIT'}, 'commit', -m => 'initial commit, shipwright creating new git repository' ] );
-    Shipwright::Util->run(
-        [ $ENV{'SHIPWRIGHT_GIT'}, 'push', $new_repos_dir, 'master' ] );
+        Shipwright::Util->run(
+            [ $ENV{'SHIPWRIGHT_GIT'}, 'add', $initial_file ] );
+        Shipwright::Util->run(
+            [
+                $ENV{'SHIPWRIGHT_GIT'},
+                'commit',
+                -m => 'initial commit, shipwright creating new git repository'
+            ]
+        );
+        Shipwright::Util->run(
+            [ $ENV{'SHIPWRIGHT_GIT'}, 'push', $new_repos_dir, 'master' ] );
 
-    chdir $cwd;
+        chdir $cwd;
 
-    Shipwright::Util->run(sub{ remove_tree( $dir ) }); #< would not be necessary if used File::Temp->newdir instead
+        Shipwright::Util->run( sub { remove_tree($dir) } )
+          ;    #< would not be necessary if used File::Temp->newdir instead
+    }
 
     return $new_repos_dir;
 }

commit bd2900054945352e3ea2b6a05bce398e8909ad0d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 13 07:59:10 2009 +0800

    don't need to remove_tree since the $dir is created with CLEANUP => 1

diff --git a/lib/Shipwright/Backend/Git.pm b/lib/Shipwright/Backend/Git.pm
index 7a64718..2ed3405 100644
--- a/lib/Shipwright/Backend/Git.pm
+++ b/lib/Shipwright/Backend/Git.pm
@@ -119,9 +119,6 @@ sub _init_new_git_repos {
             [ $ENV{'SHIPWRIGHT_GIT'}, 'push', $new_repos_dir, 'master' ] );
 
         chdir $cwd;
-
-        Shipwright::Util->run( sub { remove_tree($dir) } )
-          ;    #< would not be necessary if used File::Temp->newdir instead
     }
 
     return $new_repos_dir;

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



More information about the Bps-public-commit mailing list