| 1 | package Git::CPAN::Patch; | ||
| 2 | 5 | our $AUTHORITY = 'cpan:YANICK'; | |
| 3 | #ABSTRACT: Patch CPAN modules using Git | ||
| 4 | 5 | $Git::CPAN::Patch::VERSION = '2.3.2'; | |
| 5 | 6 | ▶ | use 5.10.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 6 | ▶ | use MooseX::App 1.21; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 6 | ▶ | use MooseX::SemiAffordanceAccessor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 6 | ▶ | use MetaCPAN::API; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 6 | ▶ | use Method::Signatures::Simple 1.07; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | 5 | app_base 'git-cpan'; | |
| 17 | 5 | app_namespace 'Git::CPAN::Patch::Command'; | |
| 18 | |||
| 19 | app_command_name { | ||
| 20 | 36 | ▶ | join '-', map { lc } $_[0] =~ /([A-Z]+[a-z]+)/g; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 21 | 5 | }; | |
| 22 | |||
| 23 | option man => ( | ||
| 24 | is => 'ro', | ||
| 25 | isa => 'Bool', | ||
| 26 | default => 0, | ||
| 27 | lazy => 1, | ||
| 28 | trigger => sub { | ||
| 29 | 0 | ▶ | require Pod::Usage; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 30 | 0 | my $name = $_[0]->meta->name . '.pm'; | |
| 31 | 0 | $name =~ s#::#/#g; | |
| 32 | |||
| 33 | exit Pod::Usage::pod2usage( | ||
| 34 | -verbose => 2, | ||
| 35 | 0 | -input => $INC{$name} | |
| 36 | ); | ||
| 37 | }, | ||
| 38 | 5 | documentation => q{Prints the command's manpage}, | |
| 39 | ); | ||
| 40 | |||
| 41 | 5 | has target => ( | |
| 42 | is => 'rw', | ||
| 43 | isa => 'Str', | ||
| 44 | ); | ||
| 45 | |||
| 46 | 5 | has distribution_name => ( | |
| 47 | is => 'ro', | ||
| 48 | lazy_build => 1, | ||
| 49 | ); | ||
| 50 | |||
| 51 | 5 | has distribution_meta => ( | |
| 52 | isa => 'HashRef', | ||
| 53 | is => 'ro', | ||
| 54 | lazy_build => 1, | ||
| 55 | ); | ||
| 56 | |||
| 57 | 5 | has repo => ( | |
| 58 | is => 'ro', | ||
| 59 | lazy_build => 1, | ||
| 60 | ); | ||
| 61 | |||
| 62 | 6 | ▶ | method _build_repo { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
_build_repo: not called CC=1 SCAR=0.8
| |||
| 63 | 0 | Git::Repository->new( ); | |
| 64 | 5 | } | |
| 65 | |||
| 66 | 6 | ▶ | method _build_distribution_name { |
|
Subroutine
BEGIN: called CC=1 SCAR=4.1
Subroutine
__ANON__: not called CC=1 SCAR=3.8
Subroutine
_build_distribution_name: not called CC=1 SCAR=3.8
| |||
| 67 | 0 | my $target = $self->target; | |
| 68 | |||
| 69 | 0 | $target =~ s/-/::/g; | |
| 70 | |||
| 71 | 0 | my $mcpan = MetaCPAN::API->new; | |
| 72 | |||
| 73 | 0 | return $mcpan->module( $target )->{distribution}; | |
| 74 | 5 | } | |
| 75 | |||
| 76 | 6 | ▶ | method _build_distribution_meta { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
_build_distribution_meta: not called CC=1 SCAR=0.8
| |||
| 77 | 0 | my $mcpan = MetaCPAN::API->new; | |
| 78 | |||
| 79 | 0 | $mcpan->release( distribution => $self->distribution_name ); | |
| 80 | 5 | } | |
| 81 | |||
| 82 | 5 | __PACKAGE__->meta->make_immutable; | |
| 83 | |||
| 84 | 5 | 'end of module Git::CPAN::Patch'; | |
| 85 | |||
| 86 | =pod | ||
| 87 | |||
| 88 | =encoding UTF-8 | ||
| 89 | |||
| 90 | =head1 NAME | ||
| 91 | |||
| 92 | Git::CPAN::Patch - Patch CPAN modules using Git | ||
| 93 | |||
| 94 | =head1 VERSION | ||
| 95 | |||
| 96 | version 2.3.2 | ||
| 97 | |||
| 98 | =head1 SYNOPSIS | ||
| 99 | |||
| 100 | # import a module: | ||
| 101 | |||
| 102 | % git-cpan clone Foo::Bar | ||
| 103 | % cd Foo-Bar | ||
| 104 | |||
| 105 | # hack and submit to RT | ||
| 106 | |||
| 107 | # it's probably best to work in a branch | ||
| 108 | % git checkout -b blah | ||
| 109 | |||
| 110 | ... hack lib/Foo/Bar.pm ... | ||
| 111 | |||
| 112 | % git commit -am "blah" | ||
| 113 | % git-cpan sendpatch | ||
| 114 | |||
| 115 | # update the module | ||
| 116 | # this automatically rebases the current branch | ||
| 117 | % git-cpan update | ||
| 118 | |||
| 119 | =head1 DESCRIPTION | ||
| 120 | |||
| 121 | L<Git::CPAN::Patch> provides a suite of git commands | ||
| 122 | aimed at making trivially | ||
| 123 | easy the process of grabbing | ||
| 124 | any distribution off CPAN, stuffing it | ||
| 125 | in a local git repository and, once gleeful | ||
| 126 | hacking has been perpetrated, sending back | ||
| 127 | patches to its maintainer. | ||
| 128 | |||
| 129 | NOTE: This module is supported in Linux, BSD, and the like. This | ||
| 130 | module is B<not> supported in Microsoft Windows (Cygwin, Strawberry Perl). | ||
| 131 | See L<CPAN Testers Matrix|http://matrix.cpantesters.org/?dist=Git-CPAN-Patch> | ||
| 132 | for currently supported operating systems. | ||
| 133 | |||
| 134 | =head1 GIT-CPAN COMMANDS | ||
| 135 | |||
| 136 | =over | ||
| 137 | |||
| 138 | =item L<clone|Git::CPAN::Patch::Command::Clone> | ||
| 139 | |||
| 140 | Clone a CPAN module's history into a new git repository | ||
| 141 | |||
| 142 | =item L<import|Git::CPAN::Patch::Command::Import> | ||
| 143 | |||
| 144 | Import a module into a git repository. | ||
| 145 | |||
| 146 | =item L<send-email|Git::CPAN::Patch::Command::SendEmail> | ||
| 147 | |||
| 148 | Use C<git-send-email> to submit patches to CPAN RT | ||
| 149 | |||
| 150 | =item L<send-patch|Git::CPAN::Patch::Command::SendPatch> | ||
| 151 | |||
| 152 | Create patch files and submit then to RT | ||
| 153 | |||
| 154 | =item L<update|Git::CPAN::Patch::Command::Update> | ||
| 155 | |||
| 156 | Import the latest version of a module and rebase the current branch | ||
| 157 | |||
| 158 | =item L<format-patch|Git::CPAN::Patch::Command::FormatPatch> | ||
| 159 | |||
| 160 | Format patches using C<cpan/master> as the origin reference | ||
| 161 | |||
| 162 | =item L<squash|Git::CPAN::Patch::Command::Squash> | ||
| 163 | |||
| 164 | Combine multiple commits into one patch | ||
| 165 | |||
| 166 | =item L<which|Git::CPAN::Patch::Command::Which> | ||
| 167 | |||
| 168 | Report upon the managed module | ||
| 169 | |||
| 170 | =back | ||
| 171 | |||
| 172 | =head1 AUTHORS | ||
| 173 | |||
| 174 | Yanick Champoux C<< <yanick@cpan.org> >> | ||
| 175 | |||
| 176 | Yuval Kogman C<< <nothingmuch@woobling.org> >> | ||
| 177 | |||
| 178 | =head1 SEE ALSO | ||
| 179 | |||
| 180 | =head2 Articles | ||
| 181 | |||
| 182 | The set of scripts that would eventually become | ||
| 183 | L<Git::CPAN::Patch> were first presented in the | ||
| 184 | article I<CPAN Patching with Git>, published in | ||
| 185 | issue 5.1 of L<The Perl Review|http://theperlreview.com>. | ||
| 186 | |||
| 187 | =head1 AUTHOR | ||
| 188 | |||
| 189 | Yanick Champoux <yanick@cpan.org> | ||
| 190 | |||
| 191 | =head1 COPYRIGHT AND LICENSE | ||
| 192 | |||
| 193 | This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009 by Yanick Champoux. | ||
| 194 | |||
| 195 | This is free software; you can redistribute it and/or modify it under | ||
| 196 | the same terms as the Perl 5 programming language system itself. | ||
| 197 | |||
| 198 | =cut | ||
| 199 | |||
| 200 | __END__ | ||
| 201 | |||
| 202 | # TODO add back --compose to sendpatch | ||
| 203 | |||
| 204 | |||
| 205 | |||
| 206 | |||