File Coverage

blib/lib/Pinto/Action/Pull.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Pull upstream distributions into the repository
2              
3             package Pinto::Action::Pull;
4              
5 11     11   16337 use Moose;
  11         3284  
  11         220  
6 11     11   96823 use MooseX::StrictConstructor;
  11         54  
  11         199  
7 11     11   46961 use MooseX::Types::Moose qw(Bool);
  11         47  
  11         272  
8 11     11   61968 use MooseX::MarkAsMethods ( autoclean => 1 );
  11         52  
  11         172  
9              
10 11     11   52550 use Try::Tiny;
  11         47  
  11         1239  
11              
12 11     11   95 use Pinto::Util qw(throw);
  11         39  
  11         873  
13 11     11   96 use Pinto::Types qw(TargetList);
  11         35  
  11         171  
14              
15             #------------------------------------------------------------------------------
16              
17             our $VERSION = '0.14'; # VERSION
18              
19             #------------------------------------------------------------------------------
20              
21             extends qw( Pinto::Action );
22              
23             #------------------------------------------------------------------------------
24              
25             has targets => (
26             isa => TargetList,
27             traits => [qw(Array)],
28             handles => { targets => 'elements' },
29             required => 1,
30             coerce => 1,
31             );
32              
33             has no_fail => (
34             is => 'ro',
35             isa => Bool,
36             default => 0,
37             );
38              
39             #------------------------------------------------------------------------------
40              
41             with qw( Pinto::Role::Committable Pinto::Role::Puller );
42              
43             #------------------------------------------------------------------------------
44              
45             sub execute {
46             my ($self) = @_;
47              
48             my $stack = $self->stack;
49              
50             for my $target ( $self->targets ) {
51              
52             try {
53             $self->repo->svp_begin;
54             $self->notice( "Pulling target $target to stack $stack");
55             my ($dist, $did_pull, $did_pull_prereqs) = $self->pull( target => $target );
56             $self->notice("Target $target is already on stack $stack") unless $did_pull;
57             push @{$self->affected}, $dist if $did_pull || $did_pull_prereqs;
58             }
59             catch {
60             throw $_ unless $self->no_fail;
61             $self->result->failed( because => $_ );
62              
63             $self->repo->svp_rollback;
64              
65             $self->error($_);
66             $self->error("Target $target failed...continuing anyway");
67             }
68             finally {
69             my ($error) = @_;
70             $self->repo->svp_release unless $error;
71             };
72             }
73              
74             $self->chrome->progress_done;
75              
76             return $self;
77             }
78              
79             #------------------------------------------------------------------------------
80              
81             __PACKAGE__->meta->make_immutable;
82              
83             #------------------------------------------------------------------------------
84              
85             1;
86              
87             __END__
88              
89             =pod
90              
91             =encoding UTF-8
92              
93             =for :stopwords Jeffrey Ryan Thalhammer
94              
95             =head1 NAME
96              
97             Pinto::Action::Pull - Pull upstream distributions into the repository
98              
99             =head1 VERSION
100              
101             version 0.14
102              
103             =head1 AUTHOR
104              
105             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
110              
111             This is free software; you can redistribute it and/or modify it under
112             the same terms as the Perl 5 programming language system itself.
113              
114             =cut