File Coverage

blib/lib/App/Sqitch/Command/upgrade.pm
Criterion Covered Total %
statement 41 41 100.0
branch 3 4 75.0
condition n/a
subroutine 11 11 100.0
pod 1 1 100.0
total 56 57 98.2


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 2     2   1645 use strict;
  2         6  
4 2     2   10 use warnings;
  2         4  
  2         50  
5 2     2   8 use utf8;
  2         3  
  2         51  
6 2     2   9 use Moo;
  2         4  
  2         9  
7 2     2   51 use App::Sqitch::Types qw(URI Maybe Str Bool HashRef);
  2         4  
  2         11  
8 2     2   696 use Locale::TextDomain qw(App-Sqitch);
  2         7  
  2         20  
9 2     2   2125 use App::Sqitch::X qw(hurl);
  2         5  
  2         16  
10 2     2   386 use List::Util qw(first);
  2         5  
  2         27  
11 2     2   628 use namespace::autoclean;
  2         4  
  2         128  
12 2     2   14 extends 'App::Sqitch::Command';
  2         3  
  2         13  
13             with 'App::Sqitch::Role::ConnectingCommand';
14              
15             our $VERSION = 'v1.3.0'; # VERSION
16              
17             has target => (
18             is => 'ro',
19             isa => Str,
20             );
21              
22             return qw(
23             target|t=s
24             );
25             }
26              
27             my $self = shift;
28             my ($targets) = $self->parse_args(
29             target => $self->target,
30 5     5 1 4655 args => \@_,
31 5         30 );
32              
33             # Warn on multiple targets.
34             my $target = shift @{ $targets };
35             $self->warn(__x(
36             'Too many targets specified; using {target}',
37 5         8 target => $target->name,
  5         9  
38             )) if @{ $targets };
39              
40             my $engine = $target->engine;
41 5 50       6  
  5         12  
42             if ($engine->needs_upgrade) {
43 5         95 $self->info(__x(
44             'Upgrading registry {registry} to version {version}',
45 5 100       751 registry => $engine->registry_destination,
46 1         8 version => $engine->registry_release,
47             ));
48             $engine->upgrade_registry;
49             } else {
50             $self->info(__x(
51 1         139 'Registry {registry} is up-to-date at version {version}',
52             registry => $engine->registry_destination,
53 4         33 version => $engine->registry_release,
54             ));
55             }
56              
57             return $self;
58             }
59              
60 5         961 1;
61              
62              
63             =head1 Name
64              
65             App::Sqitch::Command::upgrade - Upgrade the Sqitch registry
66              
67             =head1 Synopsis
68              
69             my $cmd = App::Sqitch::Command::upgrade->new(%params);
70             $cmd->execute;
71              
72             =head1 Description
73              
74             If you want to know how to use the C<upgrade> command, you probably want to be
75             reading C<sqitch-upgrade>. But if you really want to know how the C<upgrade>
76             command works, read on.
77              
78             =head1 Interface
79              
80             =head2 Class Methods
81              
82             =head3 C<options>
83              
84             my @opts = App::Sqitch::Command::upgrade->options;
85              
86             Returns a list of L<Getopt::Long> option specifications for the command-line
87             options for the C<upgrade> command.
88              
89             =head2 Attributes
90              
91             =head3 C<target>
92              
93             The upgrade target.
94              
95             =head2 Instance Methods
96              
97             =head3 C<execute>
98              
99             $upgrade->execute;
100              
101             Executes the upgrade command.
102              
103             =head1 See Also
104              
105             =over
106              
107             =item L<sqitch-upgrade>
108              
109             Documentation for the C<upgrade> command to the Sqitch command-line client.
110              
111             =item L<sqitch>
112              
113             The Sqitch command-line client.
114              
115             =back
116              
117             =head1 Author
118              
119             David E. Wheeler <david@justatheory.com>
120              
121             =head1 License
122              
123             Copyright (c) 2012-2022 iovation Inc., David E. Wheeler
124              
125             Permission is hereby granted, free of charge, to any person obtaining a copy
126             of this software and associated documentation files (the "Software"), to deal
127             in the Software without restriction, including without limitation the rights
128             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
129             copies of the Software, and to permit persons to whom the Software is
130             furnished to do so, subject to the following conditions:
131              
132             The above copyright notice and this permission notice shall be included in all
133             copies or substantial portions of the Software.
134              
135             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
136             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
137             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
138             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
139             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
140             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
141             SOFTWARE.
142              
143             =cut