This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit 8a118186d4286d7cfc3e058d6c9bff4199266465
Author: Masahiro Chiba <ch...@everqueue.com>
Date:   Thu Nov 10 18:37:25 2011 +0900

    support specify multiple mirror
---
 lib/Carton.pm         | 10 ++++++++--
 xt/cli/mirror_multi.t | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/lib/Carton.pm b/lib/Carton.pm
index 15a2cdc..4e7e14d 100644
--- a/lib/Carton.pm
+++ b/lib/Carton.pm
@@ -97,11 +97,17 @@ sub install_conservative {
 
     my $mirror = $self->{mirror} || $DefaultMirror;
 
+    my $is_default_mirror = 0;
+    if ( !ref $mirror ) {
+        $is_default_mirror = $mirror eq $DefaultMirror ? 1 : 0;
+        $mirror = [split /,/, $mirror];
+    }
+
     $self->run_cpanm(
-        "--mirror", $mirror,
+        (map { ("--mirror", $_) } @{$mirror}),
         "--mirror", "http://backpan.perl.org/";, # fallback
         "--skip-satisfied",
-        ( $mirror ne $DefaultMirror ? "--mirror-only" : () ),
+        ( $is_default_mirror ? () : "--mirror-only" ),
         ( $self->lock ? ("--mirror-index", $self->{mirror_file}) : () ),
         ( $cascade ? "--cascade-search" : () ),
         @$modules,
diff --git a/xt/cli/mirror_multi.t b/xt/cli/mirror_multi.t
new file mode 100644
index 0000000..36a0df4
--- /dev/null
+++ b/xt/cli/mirror_multi.t
@@ -0,0 +1,34 @@
+use strict;
+use Test::More;
+use xt::CLI;
+use Cwd;
+
+my $cwd = Cwd::cwd();
+
+{
+    # split string
+    my $app = cli();
+
+    $app->carton->{mirror} = "$cwd/xt/mirror,http://cpan.metacpan.org/";;
+    $app->run("install", "PSGI");
+
+    $app->run("list");
+    like $app->output, qr/^PSGI-/;
+}
+
+{
+    # ARRAY ref
+    my $app = cli();
+
+    $app->carton->{mirror} = ["$cwd/xt/mirror", "http://cpan.metacpan.org/";];
+    $app->run("install", "PSGI");
+
+    $app->run("list");
+    like $app->output, qr/^PSGI-/;
+}
+
+
+done_testing;
+
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/carton.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to