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

? sunnavy sunnavy at bestpractical.com
Wed Jun 9 07:42:17 EDT 2010


The branch, master has been updated
       via  f35406f76bd8447f5cd93d3816beb11952d4b8f6 (commit)
      from  9579ee95f25e67cd15444666ab45b8b3c9d8e496 (commit)

Summary of changes:
 lib/Shipwright/Script/Import.pm |    5 ++++-
 lib/Shipwright/Source/Base.pm   |   23 ++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit f35406f76bd8447f5cd93d3816beb11952d4b8f6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jun 9 19:39:39 2010 +0800

    add --skip-installed for import cmd

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index d358088..8b1b2b0 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -7,7 +7,7 @@ use base qw/App::CLI::Command Class::Accessor::Fast Shipwright::Script/;
 __PACKAGE__->mk_accessors(
     qw/comment no_follow build_script require_yml include_dual_lifed
       name test_script extra_tests overwrite min_perl_version skip version as
-      skip_recommends skip_all_recommends/
+      skip_recommends skip_all_recommends skip_installed/
 );
 
 use Shipwright;
@@ -34,6 +34,7 @@ sub options {
         'as=s'                => 'as',
         'skip-recommends=s'   => 'skip_recommends',
         'skip-all-recommends' => 'skip_all_recommends',
+        'skip-installed'      => 'skip_installed',
         'include-dual-lifed'  => 'include_dual_lifed'
     );
 }
@@ -125,6 +126,7 @@ sub run {
                 version             => $self->version,
                 skip_recommends     => $self->skip_recommends,
                 skip_all_recommends => $self->skip_all_recommends,
+                skip_installed      => $self->skip_installed,
             );
 
             confess_or_die "cpan dists can't be branched"
@@ -442,6 +444,7 @@ Shipwright::Script::Import - Import sources and their dependencies
  --skip-recommends              : specify a list of modules/dist names of
                                   which recommends we don't want to import
  --skip-all-recommends          : skip all the recommends to import
+ --skip-installed               : skip all the installed modules to import
  --include-dual-lifed           : include modules which live both in the perl core 
                                   and on CPAN
  
diff --git a/lib/Shipwright/Source/Base.pm b/lib/Shipwright/Source/Base.pm
index 068f0ba..544696e 100644
--- a/lib/Shipwright/Source/Base.pm
+++ b/lib/Shipwright/Source/Base.pm
@@ -9,12 +9,13 @@ use Shipwright::Source;
 use Shipwright::Util;
 use Cwd qw/getcwd/;
 use File::Copy::Recursive qw/rcopy/;
+use UNIVERSAL::require;
 
 use base qw/Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
     qw/source directory scripts_directory download_directory follow
       min_perl_version map_path skip map skip_recommends skip_all_recommends
-      include_dual_lifed
+      skip_installed include_dual_lifed
       keep_build_requires name log url_path version_path branches_path version/
 );
 
@@ -448,6 +449,25 @@ EOF
                     next;
                 }
 
+                if ( $self->skip_installed ) {
+                    if ( $module->require ) {
+                        $self->log->info("found installed $module");
+                        no strict 'refs';
+                        require version;
+                        my $installed_version = ${ $module . '::VERSION' };
+                        if ( $installed_version
+                            && version->parse($installed_version) >=
+                            version->parse($version) )
+                        {
+                            $self->log->info(
+"$module is skipped because it's installed and the version is good enough"
+                            );
+                            delete $require->{$type}{$module};
+                            next;
+                        }
+                    }
+                }
+
                 my $name = $module;
 
                 if ( $self->_is_skipped($module) ) {
@@ -630,6 +650,7 @@ sub _is_skipped {
             return 1;
         }
     }
+
     return;
 }
 

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



More information about the Bps-public-commit mailing list