| 1 | # ---------------------------------------------------------------------- copyright and license --- | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # file: lib/Dist/Zilla/Plugin/Author/VDB/Hg/Tag/Add.pm | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Copyright © 2015 Van de Bugger | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # perl-Dist-Zilla-PluginBundle-Author-VDB is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 10 | # it under the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 11 | # Foundation, either version 3 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | # perl-Dist-Zilla-PluginBundle-Author-VDB is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||
| 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||||||||||||||||||||||||
| 15 | # PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||
| 18 | # perl-Dist-Zilla-PluginBundle-Author-VDB. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||
| 20 | # ---------------------------------------------------------------------- copyright and license --- | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | #pod =for test_synopsis BEGIN { die "SKIP: not a Perl code"; } | ||||||||||||||||||||||||||||
| 23 | #pod | ||||||||||||||||||||||||||||
| 24 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 25 | #pod | ||||||||||||||||||||||||||||
| 26 | #pod F<dist.in> file: | ||||||||||||||||||||||||||||
| 27 | #pod | ||||||||||||||||||||||||||||
| 28 | #pod [Author::VDB::Hg::Tag::Add] | ||||||||||||||||||||||||||||
| 29 | #pod | ||||||||||||||||||||||||||||
| 30 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 31 | #pod | ||||||||||||||||||||||||||||
| 32 | #pod This plugin does C<AfterRelease> role. It tags current version in Mercurial repository (but does | ||||||||||||||||||||||||||||
| 33 | #pod not commit the change!). | ||||||||||||||||||||||||||||
| 34 | #pod | ||||||||||||||||||||||||||||
| 35 | #pod =cut | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | package Dist::Zilla::Plugin::Author::VDB::Hg::Tag::Add; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use version 0.77; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # ABSTRACT: Add tag (but don't commit it) [after release] | ||||||||||||||||||||||||||||
| 46 | 1 | our $VERSION = 'v0.11.3.1'; # TRIAL VERSION | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | with 'Dist::Zilla::Role::AfterRelease'; | |||||||||||||||||||||||||||
| 49 | 1 | with 'Dist::Zilla::Role::ErrorLogger'; | |||||||||||||||||||||||||||
| 50 | 1 | with 'Dist::Zilla::Role::Author::VDB::HgRunner'; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 1 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | #pod =option local | ||||||||||||||||||||||||||||
| 57 | #pod | ||||||||||||||||||||||||||||
| 58 | #pod If 1, local tag will be added. | ||||||||||||||||||||||||||||
| 59 | #pod | ||||||||||||||||||||||||||||
| 60 | #pod =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | has local => ( | |||||||||||||||||||||||||||
| 63 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 64 | is => 'ro', | ||||||||||||||||||||||||||||
| 65 | default => 0, | ||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #pod =for Pod::Coverage after_release | ||||||||||||||||||||||||||||
| 71 | #pod | ||||||||||||||||||||||||||||
| 72 | #pod =cut | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub after_release { | ||||||||||||||||||||||||||
|
Subroutine
after_release: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 76 | 0 | my $root = path( $self->zilla->root ); | |||||||||||||||||||||||||||
| 77 | 0 | my $identify = $self->run_hg( 'identify', '--id', '--debug' ); | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( @$identify != 1 or $identify->[ 0 ] !~ m{ ^ ([0-9a-f]{40}) (\+?) $ }x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$identify != 1 or not $identify->[0] =~ / ^ ([0-9a-f]{40}) (\+?) $ /x
MC/DC0%0/2
@$identify != 1 or not $identify->[0] =~ / ^ ([0-9a-f]{40}) (\+?) $ /x
@$identify != 1
not $identify->[0] =~ / ^ ([0-9a-f]{40}) (\+?) $ /x
Truth table0%0/3
A or not(B)
A= @$identify != 1B= not $identify->[0] =~ / ^ ([0-9a-f]{40}) (\+?) $ /x
| |||||||||||||||||||||||||||||
| 79 | 0 | $self->log_error( "Can't parse 'hg identify' output:" ); | |||||||||||||||||||||||||||
| 80 | 0 | $self->log_error( " $_" ) for @$identify; | |||||||||||||||||||||||||||
| 81 | 0 | $self->abort(); | |||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||
| 83 | 0 | my ( $id, $dirty ) = ( $1, $2 ); ## no critic ( ProhibitCaptureWithoutTest ) | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | if ( $dirty ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | $self->abort( "The working directory has uncommitted changes" ); | |||||||||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( $id eq '0' x 40 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | $self->abort( "Oops, current changeset has null id" ); | |||||||||||||||||||||||||||
| 89 | # ^ TODO: More user-friendly error message | ||||||||||||||||||||||||||||
| 90 | }; | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $tags = $root->child( $self->local ? '.hg/localtags' : '.hgtags' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | $self->log_debug( [ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | $self->local ? "adding local tag %s" : "adding tag %s", | ||||||||||||||||||||||||||||
| 94 | $self->zilla->version | ||||||||||||||||||||||||||||
| 95 | ] ); | ||||||||||||||||||||||||||||
| 96 | 0 | $tags->append( sprintf( "%s %s\n", $id, $self->zilla->version ) ); | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( not $self->local ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | # Make sure `.hgtags` file is added to repository. | ||||||||||||||||||||||||||||
| 99 | 0 | my $status = $self->run_hg( 'status', '.hgtags' ); | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ( @$status != 1 or $status->[ 0 ] !~ m{ ^ ([?M]) \s \.hgtags $ }x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$status != 1 or not $status->[0] =~ / ^ ([?M]) \s \.hgtags $ /x
MC/DC0%0/2
@$status != 1 or not $status->[0] =~ / ^ ([?M]) \s \.hgtags $ /x
@$status != 1
not $status->[0] =~ / ^ ([?M]) \s \.hgtags $ /x
Truth table0%0/3
A or not(B)
A= @$status != 1B= not $status->[0] =~ / ^ ([?M]) \s \.hgtags $ /x
| |||||||||||||||||||||||||||||
| 101 | 0 | $self->log_error( "Unexpected 'hg status' output:" ); | |||||||||||||||||||||||||||
| 102 | 0 | $self->log_error( [ " $_" ] ) for @$status; | |||||||||||||||||||||||||||
| 103 | 0 | $self->abort(); | |||||||||||||||||||||||||||
| 104 | }; | ||||||||||||||||||||||||||||
| 105 | 0 | my $mark = $1; ## no critic ( ProhibitCaptureWithoutTest ) | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( $mark eq '?' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | $self->run_hg( 'add', '.hgtags' ); | |||||||||||||||||||||||||||
| 108 | }; | ||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||
| 110 | 0 | return; | |||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | 1; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | #pod =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 122 | #pod | ||||||||||||||||||||||||||||
| 123 | #pod Copyright (C) 2015 Van de Bugger | ||||||||||||||||||||||||||||
| 124 | #pod | ||||||||||||||||||||||||||||
| 125 | #pod License GPLv3+: The GNU General Public License version 3 or later | ||||||||||||||||||||||||||||
| 126 | #pod <http://www.gnu.org/licenses/gpl-3.0.txt>. | ||||||||||||||||||||||||||||
| 127 | #pod | ||||||||||||||||||||||||||||
| 128 | #pod This is free software: you are free to change and redistribute it. There is | ||||||||||||||||||||||||||||
| 129 | #pod NO WARRANTY, to the extent permitted by law. | ||||||||||||||||||||||||||||
| 130 | #pod | ||||||||||||||||||||||||||||
| 131 | #pod | ||||||||||||||||||||||||||||
| 132 | #pod =cut | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # end of file # | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||||||||||||