App-Sqitch
view release on metacpan or search on metacpan
lib/App/Sqitch/Command/checkout.pm view on Meta::CPAN
package App::Sqitch::Command::checkout;
use 5.010;
use strict;
use warnings;
use utf8;
use Moo;
use App::Sqitch::Types qw(Str);
use Locale::TextDomain qw(App-Sqitch);
use App::Sqitch::X qw(hurl);
use App::Sqitch::Plan;
use Path::Class qw(dir);
use Try::Tiny;
use namespace::autoclean;
extends 'App::Sqitch::Command';
with 'App::Sqitch::Role::RevertDeployCommand';
our $VERSION = 'v1.6.1'; # VERSION
has client => (
is => 'ro',
isa => Str,
lazy => 1,
default => sub {
my $sqitch = shift->sqitch;
return $sqitch->config->get( key => 'core.vcs.client' )
|| 'git' . ( App::Sqitch::ISWIN ? '.exe' : '' );
},
);
sub configure { {} }
sub execute {
my $self = shift;
my ($branch, $targets) = $self->parse_args(
target => $self->target,
names => [undef],
args => \@_,
no_changes => 1,
);
# Branch required.
$self->usage unless length $branch;
# Warn on multiple targets.
my $target = shift @{ $targets };
$self->warn(__x(
'Too many targets specified; connecting to {target}',
target => $target->name,
)) if @{ $targets };
# Now get to work.
my $sqitch = $self->sqitch;
my $git = $self->client;
my $engine = $target->engine;
$engine->with_verify( $self->verify );
$engine->log_only( $self->log_only );
$engine->lock_timeout( $self->lock_timeout );
# What branch are we on?
my $current_branch = $sqitch->probe($git, qw(rev-parse --abbrev-ref HEAD));
hurl {
ident => 'checkout',
message => __x('Already on branch {branch}', branch => $branch),
exitval => 1,
} if $current_branch eq $branch;
# Instantitate a plan without calling $target->plan.
my $from_plan = App::Sqitch::Plan->new(
sqitch => $sqitch,
target => $target,
);
( run in 0.717 second using v1.01-cache-2.11-cpan-98e64b0badf )