blib/lib/Dist/Zilla/Plugin/SVK/Push.pm untested

filter: Statementstmt 0.0% 0 / 69 Branchbran n/a Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 100 CC 1 SCAR 6.9
CC
1
Cov
0%
after_release
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use 5.008;
2 use strict;
3 use warnings;
4  
5 package Dist::Zilla::Plugin::SVK::Push;
6 # ABSTRACT: push current branch
7  
8 use SVK;
9 use SVK::XD;
10 use SVK::Util qw/find_dotsvk/;
11 use File::Basename;
12  
13 use Moose;
14 use MooseX::Has::Sugar;
15 use MooseX::Types::Moose qw{ ArrayRef Str };
16 use String::Formatter method_stringf => {
17 -as => '_format_tag',
18 codes => {
19 d => sub { require DateTime;
20 DateTime->now->format_cldr($_[1] || 'dd-MMM-yyyy') },
21 n => sub { "\n" },
22 N => sub { $_[0]->name },
23 v => sub { $_[0]->version },
24 },
25 };
26  
27 with 'Dist::Zilla::Role::AfterRelease';
28  
29 # sub mvp_multivalue_args { qw(push_to) }
30  
31 # -- attributes
32  
33 has push_to => (
34 is => 'rw',
35 isa => 'Str',
36 lazy => 1,
37 default => "//mirror",
38 );
39  
40 sub after_release {
41 my $self = shift;
42 # push everything on remote branch
43 $self->log("pushing to remote");
44 system( 'svk push' );
45 $self->log_debug( "The local changes" );
46 my $tagger = $self->zilla->plugin_named('SVK::Tag');
47 my $project = $tagger->project || $self->zilla->name;
48 my $project_dir = lc $project;
49 $project_dir =~ s/::/-/g;
50 my $tag_dir = $tagger->tag_directory;
51 my $firstpart = qr|^/([^/]*)|;
52 my $info = qx "svk info";
53 $info =~ m/^.*\n[^\/]*(\/.*)$/m; my $depotpath = $1;
54 ( my $depotname = $depotpath ) =~ s|$firstpart.*$|$1|;
55 $depotpath = dirname( $depotpath ) until basename( $depotpath ) eq
56 $project_dir or basename( $depotpath ) eq $depotname
57 or basename( $depotpath ) eq '/';
58 my $remote = $self->push_to;
59 my $tag_format = $tagger->tag_format;
60 my $tag_message = $tagger->tag_message;
61 my $tag = _format_tag($tag_format, $self->zilla);
62 my $message = _format_tag($tag_message, $self->zilla);
63 my $localtagpath = "$depotpath/$tag_dir/$tag";
64 my $remotetagpath = "$remote/$project_dir/$tag_dir/$tag";
65 system( "svk mkdir $remotetagpath -m $message" );
66 system( "svk smerge --baseless $localtagpath $remotetagpath -m $message" );
67 # system( "svk cp $localtagpath $remotetagpath -m $message" );
68 $self->log_debug( "The tags too" );
69 }
70  
71 1;
72  
73  
74 =pod
75  
76 =head1 NAME
77  
78 Dist::Zilla::Plugin::SVK::Push - push current branch
79  
80 =head1 VERSION
81  
82 version 0.10
83  
84 =head1 SYNOPSIS
85  
86 In your F<dist.ini>:
87  
88 [SVK::Push]
89 push_to = //mirror ; this is the default, the project is underneath
90  
91 =head1 DESCRIPTION
92  
93 Once the release is done, this plugin will push current svk branch to
94 remote that it was copied from, but the associated tags need the mirror name.
95  
96 The plugin accepts the following options:
97  
98 =over 4
99  
100 =item *
101  
102 push_to - the name of the remote repo to push to. The default is F<//mirror>. The project and tags subdirectories underneath the remote are from F<Tag.pm>,
103  
104 =back
105  
106 =for Pod::Coverage after_release
107 mvp_multivalue_args
108  
109 =head1 AUTHOR
110  
111 Dr Bean <drbean at (a) cpan dot (.) org>
112  
113 =head1 COPYRIGHT AND LICENSE
114  
115 This software is copyright (c) 2010 by Dr Bean.
116  
117 This is free software; you can redistribute it and/or modify it under
118 the same terms as the Perl 5 programming language system itself.
119  
120 =cut
121  
122  
123 __END__