Permalink
Browse files

Support git URL as an installation target.

Cherry-picked from https://github.com/miyagawa/cpanminus/pull/165/commits

TODO:
* Support extract configure_requires from cpanfile
* Add git-URL from 02packages and/or cpanfile
  • Loading branch information...
1 parent 9d654d7 commit 6419e1dcf52184a7c1e6eca479e41a25647e1582 @miyagawa committed Feb 5, 2013
Showing with 33 additions and 0 deletions.
  1. +22 −0 lib/App/cpanminus/script.pm
  2. +11 −0 xt/git_uri.t
@@ -7,6 +7,7 @@ use File::Find ();
use File::Path ();
use File::Spec ();
use File::Copy ();
+use File::Temp ();
use Getopt::Long ();
use Parse::CPAN::Meta;
use Symbol ();
@@ -1391,6 +1392,11 @@ sub resolve_name {
};
}
+ # Git
+ if ($module =~ /(^git:|\.git$)/) {
+ return $self->git_uri($module);
+ }
+
# cpan URI
if ($module =~ s!^cpan:///distfile/!!) {
return $self->cpan_dist($module);
@@ -1442,6 +1448,22 @@ sub cpan_dist {
};
}
+sub git_uri {
+ my ($self, $uri) = @_;
+
+ my $dh = File::Temp->newdir(CLEANUP => 1);
+ my $dir = Cwd::abs_path($dh->dirname);
+
+ my $cmd = "git clone $uri $dir";
+ $self->run($cmd);
+
+ return {
+ source => 'local',
+ dir => $dir,
+ handle => $dh,
+ };
+}
+
sub setup_module_build_patch {
my $self = shift;
View
@@ -0,0 +1,11 @@
+use strict;
+use Test::More;
+use xt::Run;
+
+my $local_lib = "$ENV{PERL_CPANM_HOME}/perl5";
+
+run "-L", $local_lib, "git://github.com/miyagawa/cpanminus.git";
+like last_build_log, qr/installed/;
+
+done_testing;
+

0 comments on commit 6419e1d

Please sign in to comment.