File Coverage

blib/lib/Pinto/Action/Log.pm
Criterion Covered Total %
statement 34 38 89.4
branch 1 4 25.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 44 52 84.6


line stmt bran cond sub pod time code
1             # ABSTRACT: Show revision log for a stack
2              
3             package Pinto::Action::Log;
4              
5 1     1   616 use Moose;
  1         4  
  1         15  
6 1     1   7811 use MooseX::StrictConstructor;
  1         5  
  1         21  
7 1     1   4014 use MooseX::Types::Moose qw(Str Bool);
  1         3  
  1         22  
8 1     1   4690 use MooseX::MarkAsMethods ( autoclean => 1 );
  1         3  
  1         13  
9              
10 1     1   5078 use Pinto::Difference;
  1         4  
  1         18  
11 1     1   544 use Pinto::RevisionWalker;
  1         4  
  1         9  
12 1     1   45 use Pinto::Constants qw(:color);
  1         2  
  1         77  
13 1     1   114 use Pinto::Types qw(StackName StackDefault DiffStyle);
  1         1  
  1         8  
14              
15             #------------------------------------------------------------------------------
16              
17             our $VERSION = '0.14'; # VERSION
18              
19             #------------------------------------------------------------------------------
20              
21             extends qw( Pinto::Action );
22              
23             #------------------------------------------------------------------------------
24              
25             has stack => (
26             is => 'ro',
27             isa => StackName | StackDefault,
28             default => undef,
29             );
30              
31             has with_diffs => (
32             is => 'ro',
33             isa => Bool,
34             default => 0,
35             );
36              
37             has diff_style => (
38             is => 'ro',
39             isa => DiffStyle,
40             predicate => 'has_diff_style',
41             );
42              
43              
44             #------------------------------------------------------------------------------
45              
46             sub execute {
47 2     2 0 11 my ($self) = @_;
48              
49 2         67 my $stack = $self->repo->get_stack( $self->stack );
50 2         96 my $walker = Pinto::RevisionWalker->new( start => $stack->head );
51              
52 2         10 while ( my $revision = $walker->next ) {
53              
54 3         75 my $revid = $revision->to_string("revision %I");
55 3         144 $self->show( $revid, { color => $PINTO_PALETTE_COLOR_1 } );
56              
57 3         14 my $rest = $revision->to_string("Date: %u\nUser: %j\n\n%{4}G\n");
58 3         119 $self->show($rest);
59              
60 3 50       87 if ($self->with_diffs) {
61 0         0 my $parent = ($revision->parents)[0];
62 0 0       0 local $ENV{PINTO_DIFF_STYLE} = $self->diff_style if $self->has_diff_style;
63 0         0 my $diff = Pinto::Difference->new(left => $parent, right => $revision);
64 0         0 $self->show($diff);
65             }
66             }
67              
68 2         338 return $self->result;
69             }
70              
71             #------------------------------------------------------------------------------
72              
73             __PACKAGE__->meta->make_immutable;
74              
75             #------------------------------------------------------------------------------
76              
77             1;
78              
79             __END__
80              
81             =pod
82              
83             =encoding UTF-8
84              
85             =for :stopwords Jeffrey Ryan Thalhammer
86              
87             =head1 NAME
88              
89             Pinto::Action::Log - Show revision log for a stack
90              
91             =head1 VERSION
92              
93             version 0.14
94              
95             =head1 AUTHOR
96              
97             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
102              
103             This is free software; you can redistribute it and/or modify it under
104             the same terms as the Perl 5 programming language system itself.
105              
106             =cut