| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 1448 | use 5.010001; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 151 |  | 
| 2 | 1 |  |  | 1 |  | 7 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 3 | 1 |  |  | 1 |  | 17 | use warnings; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 87 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | package Dist::Inkt::Role::Hg; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $AUTHORITY = 'cpan:TOBYINK'; | 
| 8 |  |  |  |  |  |  | our $VERSION   = '0.004'; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 |  | 899 | use Moose::Role; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | use File::chdir; | 
| 12 |  |  |  |  |  |  | use Types::Standard 'Bool'; | 
| 13 |  |  |  |  |  |  | use namespace::autoclean; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | has source_control_is_hg => ( | 
| 16 |  |  |  |  |  |  | is      => "ro", | 
| 17 |  |  |  |  |  |  | isa     => Bool, | 
| 18 |  |  |  |  |  |  | lazy    => 1, | 
| 19 |  |  |  |  |  |  | builder => "_build_source_control_is_hg", | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub _build_source_control_is_hg | 
| 23 |  |  |  |  |  |  | { | 
| 24 |  |  |  |  |  |  | my $self = shift; | 
| 25 |  |  |  |  |  |  | !! $self->rootdir->child(".hg")->is_dir; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | after BUILD => sub | 
| 29 |  |  |  |  |  |  | { | 
| 30 |  |  |  |  |  |  | my $self = shift; | 
| 31 |  |  |  |  |  |  | return unless $self->source_control_is_hg; | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | $self->setup_prerelease_action(sub { | 
| 34 |  |  |  |  |  |  | local $CWD = $self->rootdir; | 
| 35 |  |  |  |  |  |  | my @stat = | 
| 36 |  |  |  |  |  |  | grep !/^\?(.+)\.tar.gz/,  # allow the recently built tarball! | 
| 37 |  |  |  |  |  |  | grep /\w/, | 
| 38 |  |  |  |  |  |  | split /\r?\n/, | 
| 39 |  |  |  |  |  |  | `hg status`; | 
| 40 |  |  |  |  |  |  | if (@stat) { | 
| 41 |  |  |  |  |  |  | $self->log("Mercurial has uncommitted changes - please commit them"); | 
| 42 |  |  |  |  |  |  | $self->log($_) for @stat; | 
| 43 |  |  |  |  |  |  | system("/bin/sh"); | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  | }) if $self->can("setup_prerelease_action"); | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | $self->setup_postrelease_action(sub { | 
| 48 |  |  |  |  |  |  | my $self = shift; | 
| 49 |  |  |  |  |  |  | local $CWD = $self->rootdir; | 
| 50 |  |  |  |  |  |  | $self->log("hg tag " . $self->version); | 
| 51 |  |  |  |  |  |  | system("hg", "tag", $self->version); | 
| 52 |  |  |  |  |  |  | $self->log("hg push"); | 
| 53 |  |  |  |  |  |  | system("hg", "push"); | 
| 54 |  |  |  |  |  |  | }) if $self->can("setup_postrelease_action"); | 
| 55 |  |  |  |  |  |  | }; | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | 1; | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | __END__ | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =pod | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =encoding utf-8 | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head1 NAME | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | Dist::Inkt::Role::Hg - Mercurial-related behaviour for Dist::Inkt | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | =over | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =item * | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Prevents a release from being built if there are uncommitted changes. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =item * | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | Does an << hg tag >> and C<< hg push >> after release. | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =back | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head1 BUGS | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | Please report any bugs to | 
| 86 |  |  |  |  |  |  | L<http://rt.cpan.org/Dist/Display.html?Queue=Dist-Inkt-Role-Hg>. | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 AUTHOR | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Toby Inkster E<lt>tobyink@cpan.orgE<gt>. | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENCE | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | This software is copyright (c) 2014 by Toby Inkster. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 99 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head1 DISCLAIMER OF WARRANTIES | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | 
| 105 |  |  |  |  |  |  | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | 
| 106 |  |  |  |  |  |  | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
| 107 |  |  |  |  |  |  |  |