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

? sunnavy sunnavy at bestpractical.com
Mon Feb 28 05:51:04 EST 2011


The branch, master has been updated
       via  4163cdcb23b995088555e2d24e98122aeccc21d6 (commit)
       via  e3ce1b654bcf6a7bbb94077b46723f5af1e6de6c (commit)
       via  55d0c1c3ba61dc0c2c13d00ab155e334f2bad53e (commit)
       via  c1ed0d40cfafae858596237762f1eabca7a73675 (commit)
       via  519b9052c71861fd074ba1ad767dba51e1f162d7 (commit)
       via  d2f7acc9d42fd9d95cd822b40dd829df9ae66f3f (commit)
       via  05a50cba2ac56cbb9eeca0b034af3179512c3560 (commit)
       via  1cae08d4d5fb7a7442039cd828f19162d501e84a (commit)
      from  51e3f32d60ec3b106d9052cc41da55d01283d098 (commit)

Summary of changes:
 lib/Shipwright/Backend/Base.pm    |   13 +++++++--
 lib/Shipwright/Script/Import.pm   |   49 ++++++++++++++++++++++++++++++-------
 lib/Shipwright/Script/Update.pm   |   12 +++++++-
 lib/Shipwright/Source/Shipyard.pm |   17 ++++++++----
 t/07.script.t                     |    1 +
 5 files changed, 72 insertions(+), 20 deletions(-)

- Log -----------------------------------------------------------------
commit 1cae08d4d5fb7a7442039cd828f19162d501e84a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:31:35 2011 +0800

    import dist from another shipyard: all branches or none at all

diff --git a/lib/Shipwright/Source/Shipyard.pm b/lib/Shipwright/Source/Shipyard.pm
index 9d94e04..09e6474 100644
--- a/lib/Shipwright/Source/Shipyard.pm
+++ b/lib/Shipwright/Source/Shipyard.pm
@@ -15,8 +15,7 @@ sub run {
     my $self = shift;
 
     $self->log->info( "prepare to run source: " . $self->source );
-    my ( $base, $dist, $branch ) = $self->source =~ m{(.*)/([^/]+)(?:/(.+))?};
-    $branch ||= 'vendor';
+    my ( $base, $dist ) = $self->source =~ m{(.*)/([^/]+)};
 
     my $source_shipwright = Shipwright->new( repository => $base );
     $self->name($dist) unless $self->name;
@@ -39,10 +38,10 @@ sub run {
         path   => "/scripts/$dist",
     );
     my $source_version = $source_shipwright->backend->version->{$dist};
-    my $branches       = $source_shipwright->backend->branches;
-    $self->_update_version( $self->name || $dist, $source_version->{$branch} );
-    $self->_update_url( $self->name || $dist, 'shipwright:' . $self->source );
-    $self->_update_branches( $self->name || $dist, $branches->{$dist} );
+    my $source_branch  = %{ $source_shipwright->backend->branches || {} }->{$dist};
+    $self->_update_version( $self->name, $source_version );
+    $self->_update_url( $self->name, 'shipyard:' . $self->source );
+    $self->_update_branches( $self->name, $source_branch ) if $source_branch;
 
     # follow
     if ( $self->follow ) {

commit 05a50cba2ac56cbb9eeca0b034af3179512c3560
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:32:19 2011 +0800

    fix the bugs when import from another shipyard

diff --git a/lib/Shipwright/Backend/Base.pm b/lib/Shipwright/Backend/Base.pm
index f9ce52d..f93b03f 100644
--- a/lib/Shipwright/Backend/Base.pm
+++ b/lib/Shipwright/Backend/Base.pm
@@ -260,15 +260,22 @@ sub import {
                     $self->_add_to_order($name);
 
                     my $version = $self->version;
-                    $version->{$name}{$args{as}} = $args{version};
+                    if ( $args{as} ) {
+                        $version->{$name}{$args{as}} = $args{version};
+                    }
+                    else {
+                        $version->{$name} = $args{version};
+                    }
                     $self->version($version);
 
                     my $branches = $self->branches;
                     if ( $args{branches} ) {
 
                   # mostly this happens when import from another shipwright repo
-                        $branches->{$name} = $args{branches};
-                        $self->branches($branches);
+                        if ( %{ $args{branches} } ) {
+                            $branches->{$name} = $args{branches};
+                            $self->branches($branches);
+                        }
                     }
                     elsif (
                             $name !~ /^cpan-/ && 

commit d2f7acc9d42fd9d95cd822b40dd829df9ae66f3f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:34:11 2011 +0800

    set branches so we can import another shipyard without the vendor/vendor dir bug

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index bd1aa06..68f2ea4 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -215,16 +215,21 @@ sub run {
 
             my $branches =
               load_yaml_file( $shipwright->source->branches_path );
+            $branches ||= {} if
 
             $self->log->fatal( "importing $name" );
             $shipwright->backend->import(
                 source  => $source,
                 comment => $self->comment || 'import ' . $source,
-# import anyway for the main dist, unless it's already imported in this run
-                overwrite => $imported{$name} ? 0 : 1, 
+
+     # import anyway for the main dist, unless it's already imported in this run
+                overwrite => $imported{$name} ? 0 : 1,
                 version   => $version->{$name},
                 as        => $self->as,
-                branches => $branches->{$name},
+                branches =>
+                  $shipwright->source->isa('Shipwright::Source::Shipyard')
+                ? ( $branches->{$name} || {} )
+                : (undef),
             );
 
             $shipwright->backend->import(
@@ -336,7 +341,10 @@ sub _import_req {
                         source    => $s,
                         overwrite => $self->overwrite,
                         version   => $version->{$dist},
-                        branches  => $branches->{$dist},
+                        branches  => $shipwright->source->isa(
+                            'Shipwright::Source::Shipyard')
+                        ? ( $branches->{$dist} || {} )
+                        : (undef),
                     );
                     $shipwright->backend->import(
                         source       => $s,

commit 519b9052c71861fd074ba1ad767dba51e1f162d7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:35:44 2011 +0800

    clean warning

diff --git a/lib/Shipwright/Source/Shipyard.pm b/lib/Shipwright/Source/Shipyard.pm
index 09e6474..23a16f3 100644
--- a/lib/Shipwright/Source/Shipyard.pm
+++ b/lib/Shipwright/Source/Shipyard.pm
@@ -38,7 +38,13 @@ sub run {
         path   => "/scripts/$dist",
     );
     my $source_version = $source_shipwright->backend->version->{$dist};
-    my $source_branch  = %{ $source_shipwright->backend->branches || {} }->{$dist};
+    my $source_branch;
+    if (   $source_shipwright->backend->branches
+        && $source_shipwright->backend->branches->{$dist} )
+    {
+        $source_branch = $source_shipwright->backend->branches->{$dist};
+    }
+
     $self->_update_version( $self->name, $source_version );
     $self->_update_url( $self->name, 'shipyard:' . $self->source );
     $self->_update_branches( $self->name, $source_branch ) if $source_branch;

commit c1ed0d40cfafae858596237762f1eabca7a73675
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:38:33 2011 +0800

    test fix, we use env SHIPWRIGHT_SHIPYARD for a while

diff --git a/t/07.script.t b/t/07.script.t
index da91ccd..a61cb81 100644
--- a/t/07.script.t
+++ b/t/07.script.t
@@ -8,6 +8,7 @@ use Shipwright;
 use Shipwright::Test;
 Shipwright::Test->init;
 delete $ENV{SHIPWRIGHT_REPOSITORY};
+delete $ENV{SHIPWRIGHT_SHIPYARD};
 
 is_deeply(
     {

commit 55d0c1c3ba61dc0c2c13d00ab155e334f2bad53e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 13:52:36 2011 +0800

    we should record source url for shipyard source

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index 68f2ea4..46892ed 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -252,10 +252,18 @@ sub run {
               || {};
             my $source_url = delete $new_url->{$name};
 
-            if ( $name !~ /^cpan-/ ) {
+            if (   $name !~ /^cpan-/
+                || $shipwright->source->isa('Shipwright::Source::Shipyard') )
+            {
                 my $source = $shipwright->backend->source || {};
-                $source->{$name}{$self->as||'vendor'} = $source_url;
-                $shipwright->backend->source( $source );
+                if ( $shipwright->source->isa('Shipwright::Source::Shipyard') )
+                {
+                    $source->{$name} = $source_url;
+                }
+                else {
+                    $source->{$name}{ $self->as || 'vendor' } = $source_url;
+                }
+                $shipwright->backend->source($source);
             }
         }
 
@@ -352,6 +360,19 @@ sub _import_req {
                         build_script => $script_dir,
                         overwrite    => $self->overwrite,
                     );
+                    if (
+                        $shipwright->source->isa(
+                            'Shipwright::Source::Shipyard')
+                      )
+                    {
+                        my $new_url =
+                          load_yaml_file( $shipwright->source->url_path )
+                          || {};
+                        my $source_url = delete $new_url->{$dist};
+                        my $source = $shipwright->backend->source || {};
+                        $source->{$dist} = $source_url;
+                        $shipwright->backend->source($source);
+                    }
                 }
             }
         }

commit e3ce1b654bcf6a7bbb94077b46723f5af1e6de6c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 14:12:06 2011 +0800

    branch is arrayref

diff --git a/lib/Shipwright/Backend/Base.pm b/lib/Shipwright/Backend/Base.pm
index f93b03f..55c420c 100644
--- a/lib/Shipwright/Backend/Base.pm
+++ b/lib/Shipwright/Backend/Base.pm
@@ -272,7 +272,7 @@ sub import {
                     if ( $args{branches} ) {
 
                   # mostly this happens when import from another shipwright repo
-                        if ( %{ $args{branches} } ) {
+                        if ( @{ $args{branches} } ) {
                             $branches->{$name} = $args{branches};
                             $self->branches($branches);
                         }
diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index 46892ed..8280089 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -228,7 +228,7 @@ sub run {
                 as        => $self->as,
                 branches =>
                   $shipwright->source->isa('Shipwright::Source::Shipyard')
-                ? ( $branches->{$name} || {} )
+                ? ( $branches->{$name} || [] )
                 : (undef),
             );
 
@@ -351,7 +351,7 @@ sub _import_req {
                         version   => $version->{$dist},
                         branches  => $shipwright->source->isa(
                             'Shipwright::Source::Shipyard')
-                        ? ( $branches->{$dist} || {} )
+                        ? ( $branches->{$dist} || [] )
                         : (undef),
                     );
                     $shipwright->backend->import(

commit 4163cdcb23b995088555e2d24e98122aeccc21d6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 28 15:24:40 2011 +0800

    make update cmd work with shipyard source

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index 8280089..55abe77 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -75,8 +75,10 @@ sub run {
             $source = 'cpan:' . $r_map->{ $self->name };
         }
         elsif ($branches) {
-            $source = $source_yml->{ $self->name }{ $self->as
-                  || $branches->{ $self->name }[0] };
+            $source = $source_yml->{ $self->name };
+            if ( ref $source ) {
+                $source = $source->{ $self->as || $branches->{ $self->name }[0] };
+            }
         }
         else {
             $source = $source_yml->{$self->name};
diff --git a/lib/Shipwright/Script/Update.pm b/lib/Shipwright/Script/Update.pm
index 47234eb..34ceb6a 100644
--- a/lib/Shipwright/Script/Update.pm
+++ b/lib/Shipwright/Script/Update.pm
@@ -230,8 +230,12 @@ sub _update {
     if ( $source->{$name} ) {
         $shipwright->source(
             Shipwright::Source->new(
-                name    => $name,
-                source  => $source->{$name}{$as||$branches->{$name}[0]},
+                name   => $name,
+                source => (
+                    ref $source->{$name}
+                    ? $source->{$name}{ $as || $branches->{$name}[0] }
+                    : $source->{$name}
+                ),
                 follow  => 0,
                 version => $version,
             )
@@ -271,12 +275,16 @@ sub _update {
 
     $version = load_yaml_file( $shipwright->source->version_path );
 
+    my $branches   = $shipwright->backend->branches;
     $shipwright->backend->import(
         source    => catdir( $shipwright->source->directory, $name ),
         comment   => "update $name",
         overwrite => 1,
         version   => $version->{$name},
         as        => $as,
+        branches => $shipwright->source->isa('Shipwright::Source::Shipyard')
+        ? ( $branches->{$name} || [] )
+        : (undef),
     );
 }
 

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



More information about the Bps-public-commit mailing list