├── .gitignore ├── t └── 00_compile.t ├── .shipit ├── Changes ├── xt ├── pod.t ├── perlcritic.t └── podspell.t ├── MANIFEST.SKIP ├── Makefile.PL ├── README ├── MANIFEST └── lib └── CPAN └── Command └── Repo.pm /.gitignore: -------------------------------------------------------------------------------- 1 | META.yml 2 | Makefile 3 | inc/ 4 | pm_to_blib 5 | *~ 6 | -------------------------------------------------------------------------------- /t/00_compile.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Test::More tests => 1; 3 | 4 | BEGIN { use_ok 'CPAN::Command::Repo' } 5 | -------------------------------------------------------------------------------- /.shipit: -------------------------------------------------------------------------------- 1 | steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN 2 | git.push_to = origin 3 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension CPAN::Command::Repo 2 | 3 | 0.01 Mon Mar 30 22:11:51 2009 4 | - original version 5 | -------------------------------------------------------------------------------- /xt/pod.t: -------------------------------------------------------------------------------- 1 | use Test::More; 2 | eval "use Test::Pod 1.00"; 3 | plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; 4 | all_pod_files_ok(); 5 | -------------------------------------------------------------------------------- /xt/perlcritic.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Test::More; 3 | eval q{ use Test::Perl::Critic }; 4 | plan skip_all => "Test::Perl::Critic is not installed." if $@; 5 | all_critic_ok("lib"); 6 | -------------------------------------------------------------------------------- /MANIFEST.SKIP: -------------------------------------------------------------------------------- 1 | \bRCS\b 2 | \bCVS\b 3 | \.svn/ 4 | \.git/ 5 | ^MANIFEST\. 6 | ^Makefile$ 7 | ~$ 8 | \.old$ 9 | ^blib/ 10 | ^pm_to_blib 11 | ^MakeMaker-\d 12 | \.gz$ 13 | \.cvsignore 14 | \.shipit 15 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | use inc::Module::Install; 2 | name 'CPAN-Command-Repo'; 3 | all_from 'lib/CPAN/Command/Repo.pm'; 4 | 5 | build_requires 'Test::More'; 6 | use_test_base; 7 | auto_include_deps; 8 | author_tests('xt'); 9 | auto_set_repository; 10 | WriteAll; 11 | -------------------------------------------------------------------------------- /xt/podspell.t: -------------------------------------------------------------------------------- 1 | use Test::More; 2 | eval q{ use Test::Spelling }; 3 | plan skip_all => "Test::Spelling is not installed." if $@; 4 | add_stopwords(); 5 | set_spell_cmd("aspell -l en list"); 6 | all_pod_files_spelling_ok('lib'); 7 | __DATA__ 8 | Tatsuhiko 9 | Miyagawa 10 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is Perl module CPAN::Command::Repo. 2 | 3 | INSTALLATION 4 | 5 | CPAN::Command::Repo installation is straightforward. If your CPAN shell is set up, 6 | you should just be able to do 7 | 8 | % cpan CPAN::Command::Repo 9 | 10 | Download it, unpack it, then build it as per the usual: 11 | 12 | % perl Makefile.PL 13 | % make && make test 14 | 15 | Then install it: 16 | 17 | % make install 18 | 19 | DOCUMENTATION 20 | 21 | CPAN::Command::Repo documentation is available as in POD. So you can do: 22 | 23 | % perldoc CPAN::Command::Repo 24 | 25 | to read the documentation online with your favorite pager. 26 | 27 | Tatsuhiko Miyagawa 28 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | .gitignore 2 | Changes 3 | inc/Module/Install.pm 4 | inc/Module/Install/AuthorTests.pm 5 | inc/Module/Install/Base.pm 6 | inc/Module/Install/Can.pm 7 | inc/Module/Install/Fetch.pm 8 | inc/Module/Install/Include.pm 9 | inc/Module/Install/Makefile.pm 10 | inc/Module/Install/Metadata.pm 11 | inc/Module/Install/Repository.pm 12 | inc/Module/Install/TestBase.pm 13 | inc/Module/Install/Win32.pm 14 | inc/Module/Install/WriteAll.pm 15 | inc/Spiffy.pm 16 | inc/Test/Base.pm 17 | inc/Test/Base/Filter.pm 18 | inc/Test/Builder.pm 19 | inc/Test/Builder/Module.pm 20 | inc/Test/More.pm 21 | lib/CPAN/Command/Repo.pm 22 | Makefile.PL 23 | MANIFEST This list of files 24 | META.yml 25 | README 26 | t/00_compile.t 27 | xt/perlcritic.t 28 | xt/pod.t 29 | xt/podspell.t 30 | -------------------------------------------------------------------------------- /lib/CPAN/Command/Repo.pm: -------------------------------------------------------------------------------- 1 | package CPAN::Command::Repo; 2 | 3 | use strict; 4 | use 5.008_001; 5 | our $VERSION = '0.01'; 6 | 7 | use CPAN; 8 | use URI; 9 | 10 | push @CPAN::Complete::COMMANDS, qw( repo ); 11 | $CPAN::Shell::Help->{repo} = "open a subshell by checking out a ditribution's code repository"; 12 | 13 | sub CPAN::Shell::repo { shift->rematein("repo", @_) } 14 | sub CPAN::Module::repo { shift->rematein("repo") } 15 | 16 | sub CPAN::Distribution::repo { 17 | my $self = shift; 18 | $self->get; 19 | my $package = $self->called_for; 20 | 21 | my $meta = $self->parse_meta_yml; 22 | my $repo = $meta->{resources}{repository} 23 | or return $CPAN::Frontend->mywarn("$package doesn't have a repository set in META.yml"); 24 | 25 | my $pwd = CPAN::anycwd(); 26 | my $dir = File::Spec->catfile($CPAN::Config->{cpan_home}, 'repo'); 27 | mkdir $dir, 0777 unless -e $dir; 28 | 29 | chdir($dir) or $CPAN::Frontend->mydie("Can't chdir to $dir"); 30 | 31 | do_checkout(URI->new($repo), $package); 32 | $self->safe_chdir($pwd); 33 | } 34 | 35 | sub do_checkout { 36 | my($repo, $package) = @_; 37 | $package =~ s/::/-/g; 38 | 39 | if (-e $package && -d _) { 40 | my $ans = ExtUtils::MakeMaker::prompt("$package aleady exists. Remove it before checking out?", "yes"); 41 | if ($ans =~ /^[Yy]/) { 42 | File::Path::rmtree($package); 43 | } 44 | } 45 | 46 | my $chdir_to; 47 | if ($repo->scheme eq 'git' or $repo->path =~ /\.git$/) { 48 | !system "git", "clone", $repo, $package 49 | or $CPAN::Frontend->mydie("Can't git clone $repo"); 50 | $chdir_to = $package; 51 | } elsif ($repo->scheme eq 'svn' or $repo->scheme eq 'svn+ssh' or $repo->path =~ /trunk|branches/) { # FIXME 52 | !system "svn", "checkout", $repo, $package 53 | or $CPAN::Frontend->mydir("Can't svn checkout $repo"); 54 | $chdir_to = $package; 55 | } 56 | # CVS, Darcs, bzr, hg 57 | else { 58 | $CPAN::Frontend->mywarn("Can't get repository type of $repo"); 59 | } 60 | 61 | if ($chdir_to) { 62 | chdir $chdir_to or $CPAN::Frontend->mydie("Can't chdir to $chdir_to"); 63 | my $shell = CPAN::HandleConfig->safe_quote($CPAN::Config->{'shell'}); 64 | system $shell; 65 | } 66 | } 67 | 68 | 1; 69 | __END__ 70 | 71 | =encoding utf-8 72 | 73 | =for stopwords 74 | 75 | =head1 NAME 76 | 77 | CPAN::Command::Repo - Adds new 'repo' command to CPAN shell 78 | 79 | =head1 SYNOPSIS 80 | 81 | perl -MCPAN::Command::Repo -e 'CPAN::shell()' 82 | cpan> repo Module 83 | 84 | =head1 DESCRIPTION 85 | 86 | CPAN::Command::Repo is a plugin to CPAN.pm that adds a new command 87 | I to check out (or I) module's source code repository so 88 | that you can look at what's been changed or hack on patches and send 89 | it back. 90 | 91 | Currently this module supports I and I. 92 | 93 | =head1 AUTHOR 94 | 95 | Tatsuhiko Miyagawa Emiyagawa@bulknews.netE 96 | 97 | =head1 LICENSE 98 | 99 | This library is free software; you can redistribute it and/or modify 100 | it under the same terms as Perl itself. 101 | 102 | =head1 SEE ALSO 103 | 104 | L, L 105 | 106 | =cut 107 | --------------------------------------------------------------------------------