line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010; |
3
|
3
|
|
|
3
|
|
1758
|
use strict; |
|
3
|
|
|
|
|
11
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
58
|
|
5
|
3
|
|
|
3
|
|
14
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
69
|
|
6
|
3
|
|
|
3
|
|
13
|
use Locale::TextDomain qw(App-Sqitch); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
34
|
|
7
|
3
|
|
|
3
|
|
95
|
use App::Sqitch::X qw(hurl); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
26
|
|
8
|
3
|
|
|
3
|
|
604
|
use List::Util qw(first); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
9
|
3
|
|
|
3
|
|
880
|
use Moo; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
201
|
|
10
|
3
|
|
|
3
|
|
19
|
use App::Sqitch::Types qw(Bool Str); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
27
|
|
11
|
3
|
|
|
3
|
|
1143
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
40
|
|
12
|
|
|
|
|
|
|
extends 'App::Sqitch::Command'; |
13
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ContextCommand'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 'v1.3.0'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has target => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => Str, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has exists_only => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => Bool, |
25
|
|
|
|
|
|
|
default => 0, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return qw( |
29
|
|
|
|
|
|
|
target|t=s |
30
|
|
|
|
|
|
|
exists|e! |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my ( $class, $config, $opt ) = @_; |
35
|
|
|
|
|
|
|
$opt->{exists_only} = delete $opt->{exists} |
36
|
|
|
|
|
|
|
if exists $opt->{exists}; |
37
|
|
|
|
|
|
|
return $class->SUPER::configure( $config, $opt ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ( $self, $type, $key ) = @_; |
41
|
|
|
|
|
|
|
$self->usage unless $type && $key; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
require App::Sqitch::Target; |
44
|
22
|
|
|
22
|
1
|
23946
|
my $target = $self->target ? App::Sqitch::Target->new( |
45
|
22
|
100
|
66
|
|
|
88
|
$self->target_params, |
46
|
|
|
|
|
|
|
name => $self->target, |
47
|
21
|
|
|
|
|
98
|
) : $self->default_target; |
48
|
21
|
100
|
|
|
|
427
|
my $plan = $target->plan; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Handle tags first. |
51
|
|
|
|
|
|
|
if ( $type eq 'tag' ) { |
52
|
21
|
|
|
|
|
555
|
my $is_id = $key =~ /^[0-9a-f]{40}/; |
53
|
|
|
|
|
|
|
my $change = $plan->get( |
54
|
|
|
|
|
|
|
$is_id ? $key : ($key =~ /^@/ ? '' : '@') . $key |
55
|
21
|
100
|
|
|
|
348
|
); |
56
|
7
|
|
|
|
|
17
|
|
57
|
7
|
100
|
|
|
|
32
|
my $tag = $change ? do { |
|
|
100
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if ($is_id) { |
59
|
|
|
|
|
|
|
# It's a tag ID. |
60
|
|
|
|
|
|
|
first { $_->id eq $key } $change->tags; |
61
|
7
|
100
|
|
|
|
24
|
} else { |
62
|
4
|
100
|
|
|
|
6
|
# Tag name. |
63
|
|
|
|
|
|
|
(my $name = $key) =~ s/^[@]//; |
64
|
2
|
|
|
2
|
|
12
|
first { $_->name eq $name } $change->tags; |
|
2
|
|
|
|
|
42
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} : undef; |
67
|
2
|
|
|
|
|
7
|
unless ($tag) { |
68
|
2
|
|
|
2
|
|
11
|
return if $self->exists_only; |
|
2
|
|
|
|
|
24
|
|
69
|
|
|
|
|
|
|
hurl show => __x( 'Unknown tag "{tag}"', tag => $key ); |
70
|
|
|
|
|
|
|
} |
71
|
7
|
100
|
|
|
|
28
|
$self->emit( $tag->info ) unless $self->exists_only; |
72
|
3
|
100
|
|
|
|
12
|
return $self; |
73
|
2
|
|
|
|
|
7
|
} |
74
|
|
|
|
|
|
|
|
75
|
4
|
100
|
|
|
|
50
|
# Make sure we recognize the type. |
76
|
4
|
|
|
|
|
150
|
hurl show => __x( |
77
|
|
|
|
|
|
|
'Unknown object type "{type}', |
78
|
|
|
|
|
|
|
type => $type, |
79
|
|
|
|
|
|
|
) unless first { $type eq $_ } qw(change deploy revert verify); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Make sure we have a change object. |
82
|
|
|
|
|
|
|
my $change = $plan->get($key) or do { |
83
|
14
|
100
|
|
27
|
|
82
|
return if $self->exists_only; |
|
27
|
|
|
|
|
79
|
|
84
|
|
|
|
|
|
|
hurl show => __x( |
85
|
|
|
|
|
|
|
'Unknown change "{change}"', |
86
|
13
|
100
|
|
|
|
60
|
change => $key |
87
|
2
|
100
|
|
|
|
11
|
); |
88
|
1
|
|
|
|
|
5
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if ($type eq 'change') { |
91
|
|
|
|
|
|
|
# Just show its info. |
92
|
|
|
|
|
|
|
$self->emit( $change->info ) unless $self->exists_only; |
93
|
|
|
|
|
|
|
return $self; |
94
|
11
|
100
|
|
|
|
22
|
} |
95
|
|
|
|
|
|
|
|
96
|
6
|
100
|
|
|
|
81
|
my $meth = $change->can("$type\_file"); |
97
|
6
|
|
|
|
|
303
|
my $path = $change->$meth; |
98
|
|
|
|
|
|
|
unless (-e $path) { |
99
|
|
|
|
|
|
|
return if $self->exists_only; |
100
|
5
|
|
|
|
|
22
|
hurl show => __x('File "{path}" does not exist', path => $path); |
101
|
5
|
|
|
|
|
16
|
} |
102
|
5
|
100
|
|
|
|
372
|
hurl show => __x('"{path}" is not a file', path => $path) |
103
|
2
|
100
|
|
|
|
93
|
if $path->is_dir; |
104
|
1
|
|
|
|
|
4
|
|
105
|
|
|
|
|
|
|
return $self if $self->exists_only; |
106
|
3
|
50
|
|
|
|
136
|
|
107
|
|
|
|
|
|
|
# Assume nothing about the encoding. |
108
|
|
|
|
|
|
|
binmode STDOUT, ':raw'; |
109
|
3
|
100
|
|
|
|
24
|
$self->emit( $path->slurp(iomode => '<:raw') ); |
110
|
|
|
|
|
|
|
return $self; |
111
|
|
|
|
|
|
|
} |
112
|
2
|
|
|
|
|
10
|
|
113
|
2
|
|
|
|
|
8
|
1; |
114
|
2
|
|
|
|
|
484
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 Name |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
App::Sqitch::Command::show - Show Sqitch changes to a database |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 Synopsis |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $cmd = App::Sqitch::Command::show->new(%params); |
123
|
|
|
|
|
|
|
$cmd->execute($type, $name); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 Description |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Shows the content of a Sqitch object. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If you want to know how to use the C<show> command, you probably want to be |
130
|
|
|
|
|
|
|
reading C<sqitch-show>. But if you really want to know how the C<show> command |
131
|
|
|
|
|
|
|
works, read on. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 Interface |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 Class Methods |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head3 C<options> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my @opts = App::Sqitch::Command::show->options; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns a list of L<Getopt::Long> option specifications for the command-line |
142
|
|
|
|
|
|
|
options for the C<show> command. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 Attributes |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head3 C<exists_only> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Boolean indicating whether or not to suppress output and instead exit with |
149
|
|
|
|
|
|
|
zero status if object exists and is a valid object. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 Instance Methods |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head3 C<execute> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$show->execute; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Executes the show command. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 See Also |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=over |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item L<sqitch-show> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Documentation for the C<show> command to the Sqitch command-line client. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item L<sqitch> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The Sqitch command-line client. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 Author |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 License |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright (c) 2012-2022 iovation Inc., David E. Wheeler |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
182
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
183
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
184
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
185
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
186
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
189
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
192
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
193
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
194
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
195
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
196
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
197
|
|
|
|
|
|
|
SOFTWARE. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |