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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Oct 15 02:14:01 EDT 2009


The branch, master has been updated
       via  dce7b22f0d8deb009c955f1ad2145eb15245c516 (commit)
       via  360911a9855d76115e9d3b8c14fcbb09e3d0730b (commit)
       via  63f70b2b279c930d6cea39da4e44a07ec420a976 (commit)
       via  29e4a4af362b508d82f4ecd6cec325b86dce34ea (commit)
       via  230f577b12e9a7763d1a959ac00cc7c72e5b5902 (commit)
      from  fbac1ebf0080a8ac45116b3e01db0ab39bd2a567 (commit)

Summary of changes:
 Changes                         |    8 +++++++-
 lib/Shipwright/Backend/FS.pm    |   13 ++++++++++++-
 lib/Shipwright/Backend/Git.pm   |   14 +++++++++-----
 lib/Shipwright/Backend/SVK.pm   |   24 +++++++++++-------------
 lib/Shipwright/Backend/SVN.pm   |   12 ++++++++----
 lib/Shipwright/Script.pm        |    8 ++++++--
 lib/Shipwright/Script/Create.pm |    7 +++++++
 lib/Shipwright/Util.pm          |    2 +-
 t/01.repo_check.t               |    2 +-
 t/71.script_cmds.t              |    2 +-
 t/hello/fs.t                    |    2 +-
 11 files changed, 64 insertions(+), 30 deletions(-)

- Log -----------------------------------------------------------------
commit 230f577b12e9a7763d1a959ac00cc7c72e5b5902
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 15 13:24:31 2009 +0800

    tiny fix: cleanup tmpdir

diff --git a/t/hello/fs.t b/t/hello/fs.t
index 199b82d..3d37075 100644
--- a/t/hello/fs.t
+++ b/t/hello/fs.t
@@ -79,7 +79,7 @@ $shipwright->backend->import( name => 'hello', source => $source_dir );
 ok( -e catfile( $repo, 'sources', 'Foo-Bar', 'vendor', 'Makefile.PL' ),
     'imported ok' );
 
-my $script_dir = tempdir( 'shipwright_XXXXXX', CLEANUP => 0, TMPDIR => 1 );
+my $script_dir = tempdir( 'shipwright_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
 copy( catfile( 't', 'hello', 'scripts', 'build' ),       $script_dir );
 copy( catfile( 't', 'hello', 'scripts', 'require.yml' ), $script_dir );
 

commit 29e4a4af362b508d82f4ecd6cec325b86dce34ea
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 15 13:28:52 2009 +0800

    tiny tweak

diff --git a/lib/Shipwright/Util.pm b/lib/Shipwright/Util.pm
index 6d256d5..cd8c329 100644
--- a/lib/Shipwright/Util.pm
+++ b/lib/Shipwright/Util.pm
@@ -152,7 +152,7 @@ sub find_module {
                 if lc $name eq lc $module;
         }
     }
-    return undef;
+    return;
 }
 
 =head2 PATHS

commit 63f70b2b279c930d6cea39da4e44a07ec420a976
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 15 13:51:40 2009 +0800

    add --force arg for create cmd

diff --git a/lib/Shipwright/Script.pm b/lib/Shipwright/Script.pm
index e677fb2..734ce62 100644
--- a/lib/Shipwright/Script.pm
+++ b/lib/Shipwright/Script.pm
@@ -65,8 +65,12 @@ sub prepare {
                 log_level  => $cmd->log_level,
                 log_file   => $cmd->log_file,
             );
-            confess 'invalid repository: ' . $cmd->repository
-              unless $backend->check_repository( action => $action );
+            confess 'invalid repository: '
+              . $cmd->repository
+              unless $backend->check_repository(
+                action => $action,
+                $action eq 'create' ? ( force => $cmd->force ) : ()
+              );
         }
         else {
             confess "need repository arg\n";
diff --git a/lib/Shipwright/Script/Create.pm b/lib/Shipwright/Script/Create.pm
index 66f3596..05901c1 100644
--- a/lib/Shipwright/Script/Create.pm
+++ b/lib/Shipwright/Script/Create.pm
@@ -9,6 +9,12 @@ use base qw/App::CLI::Command Shipwright::Script/;
 use Shipwright;
 use Shipwright::Util;
 
+__PACKAGE__->mk_accessors('force');
+
+sub options {
+    ( 'f|force' => 'force' );
+}
+
 sub run {
     my $self = shift;
 
@@ -41,6 +47,7 @@ Shipwright::Script::Create - Create a project
  -l [--log-level] LOGLEVEL      : specify the log level
                                   (info, debug, warn, error, or fatal)
  --log-file FILENAME            : specify the log file
+ -f [--force]                   : delete the old one if exists
 
 =head1 AUTHORS
 

commit 360911a9855d76115e9d3b8c14fcbb09e3d0730b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 15 13:52:30 2009 +0800

    confess if repo already exists and without --force arg when create

diff --git a/lib/Shipwright/Backend/FS.pm b/lib/Shipwright/Backend/FS.pm
index 3ea125f..5dcc747 100644
--- a/lib/Shipwright/Backend/FS.pm
+++ b/lib/Shipwright/Backend/FS.pm
@@ -234,7 +234,18 @@ Check if the given repository is valid.
 
 sub check_repository {
     my $self = shift;
-    return $self->SUPER::check_repository(@_);
+    my %args = @_;
+    if ( $args{action} eq 'create' ) {
+        my $repo = $self->repository;
+        if ( $args{force} || !-e $repo ) {
+            return 1;
+        }
+        $self->log->fatal("$repo exists already");
+        return;
+    }
+    else {
+        return $self->SUPER::check_repository(@_);
+    }
 }
 
 sub _update_file {
diff --git a/lib/Shipwright/Backend/Git.pm b/lib/Shipwright/Backend/Git.pm
index b8ae154..80238f3 100644
--- a/lib/Shipwright/Backend/Git.pm
+++ b/lib/Shipwright/Backend/Git.pm
@@ -63,8 +63,7 @@ sub initialize {
     my $dir = $self->SUPER::initialize(@_);
 
     my $path = $self->repository;
-    $path =~ s!^file://!!    # this should always true since we check that before
-        or die 'sanity check failed';
+    $path =~ s!^file://!!;
 
     Shipwright::Util->run( sub { remove_tree( $path ) } );
     Shipwright::Util->run( sub { make_path( $path ) } );
@@ -154,11 +153,16 @@ sub check_repository {
     my %args = @_;
 
     if ( $args{action} eq 'create' ) {
-        if ( $self->repository =~ m{^file://} ) {
-            return 1;
+        my $repo = $self->repository;
+        if ( $repo =~ m{^file://(.*)} ) {
+            if ( $args{force} || !-e $1 ) {
+                return 1;
+            }
+            $self->log->fatal("$repo exists already");
+            return;
         }
         else {
-            $self->log->error(
+            $self->log->fatal(
                 "git backend only supports creating local repository");
             return;
         }
diff --git a/lib/Shipwright/Backend/SVK.pm b/lib/Shipwright/Backend/SVK.pm
index a3bb36f..da80ea6 100644
--- a/lib/Shipwright/Backend/SVK.pm
+++ b/lib/Shipwright/Backend/SVK.pm
@@ -270,21 +270,19 @@ sub check_repository {
 
     if ( $args{action} eq 'create' ) {
 
-        # svk always has //
-        return 1 if $self->repository =~ m{^//};
-
-        if ( $self->repository =~ m{^(/[^/]+/)} ) {
-            my $ori = $self->repository;
-            $self->repository($1);
-
-            my $info = $self->info;
-
-            # revert back
-            $self->repository($ori);
-
-            return 1 if $info;
+        my $repo = $self->repository;
+        my ( $info, $err ) = $self->info;
+        if ($err) {
+            $err =~ s{\s+$}{ };
+            $self->log->fatal( $err, "maybe root of $repo does not exist?" );
+            return;
         }
 
+        return 1
+          if $args{force} || $info =~ /not exist/ || $info =~ /Revision: 0/;
+
+        $self->log->fatal("$repo has commits already");
+        return;
     }
     else {
         return $self->SUPER::check_repository(@_);
diff --git a/lib/Shipwright/Backend/SVN.pm b/lib/Shipwright/Backend/SVN.pm
index c3431ab..78f50c3 100644
--- a/lib/Shipwright/Backend/SVN.pm
+++ b/lib/Shipwright/Backend/SVN.pm
@@ -42,6 +42,8 @@ F<svnadmin> command is expected to be in the same directory as F<svn>.
 
 =cut
 
+
+
 sub build {
     my $self = shift;
     $self->strip_repository
@@ -49,8 +51,6 @@ sub build {
     $self->SUPER::build(@_);
 }
 
-=over 4
-
 =item initialize
 
 initialize a project.
@@ -253,8 +253,12 @@ sub check_repository {
         # $err like
         # file:///tmp/svn/foo:  (Not a valid URL)
         # usually means foo doesn't exist, which is valid for create
-        return 1 if $info || $err && $err =~ m{^\Q$repo\E:}m;
-
+        if ($info) {
+            return 1 if $args{force} || $info =~ /Revision: 0/;
+            $self->log->fatal("$repo has commits already");
+            return;
+        }
+        return 1 if $err && $err =~ m{^\Q$repo\E:}m;
     }
     else {
         return $self->SUPER::check_repository(@_);
diff --git a/t/01.repo_check.t b/t/01.repo_check.t
index c5710c2..ce9b4ee 100644
--- a/t/01.repo_check.t
+++ b/t/01.repo_check.t
@@ -96,7 +96,7 @@ sub test_repo {
             my $backend = Shipwright::Backend->new( repository => $repo );
             isa_ok( $backend, 'Shipwright::Backend::' . $bk_class );
             is(
-                $backend->check_repository( action => $action ),
+                $backend->check_repository( action => $action, force => 1 ),
                 $map{$action}{$repo},
                 "$repo for action $action",
             );
diff --git a/t/71.script_cmds.t b/t/71.script_cmds.t
index 452e779..1a89655 100644
--- a/t/71.script_cmds.t
+++ b/t/71.script_cmds.t
@@ -89,7 +89,7 @@ sub start_test {
     my @cmds = (
 
         # create hello repo
-        [ ['create'], qr/created with success/, "create $repo" ],
+        [ ['create', '-f'], qr/created with success/, "create $repo" ],
 
         # non exist cmd
         [

commit dce7b22f0d8deb009c955f1ad2145eb15245c516
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 15 14:00:03 2009 +0800

    update Changes for 2.4.3

diff --git a/Changes b/Changes
index ce58200..309a174 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,12 @@
 Revision history for Shipwright
 
-2.4.3
+2.4.3 Thu Oct 15 05:53:14 GMT 2009
+
+* fix git backend:
+    before 1.6.2, git clone an empty repo doesn't work(thanks to rbuels++)
+* add -f ( --force ) argument to create cmd.
+    now shipwright will confess if repository or path already exists when
+    create without -f
 
 2.4.2 Mon Sep 21 09:46:38 CST 2009
 

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



More information about the Bps-public-commit mailing list