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