Skip to content

Commit

Permalink
Support git URL as an installation target.
Browse files Browse the repository at this point in the history
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
miyagawa committed Feb 5, 2013
1 parent 9d654d7 commit 6419e1d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/App/cpanminus/script.pm
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions xt/git_uri.t
@@ -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.