Skip to content

Commit

Permalink
Don't die when default target plan file doesn't exist.
Browse files Browse the repository at this point in the history
When parsing arguments, that is. Particularly important when the default
target and/or default plan file (sqitch.plan) doesn't exist. Resolves #324.
  • Loading branch information
theory committed Jul 13, 2017
1 parent 458c412 commit 48c17b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Revision history for Perl extension App::Sqitch
that follows them (#312).
- The `verify` command now looks for the most recent variant of a `--to`
change if it's not tag-qualified.
- Sqitch no longer returns an error when specifying a target name to
commands when the default target's plan file does not exist (#324).

0.9995 2016-07-27T09:23:55Z
- Taught the `add` command not to ignore the `--change` option.
Expand Down
2 changes: 1 addition & 1 deletion lib/App/Sqitch/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ sub parse_args {

my %engines = map { $_ => 1 } ENGINES;
for my $arg (@{ $p{args} }) {
if ( !$p{no_changes} && $target && $target->plan->contains($arg) ) {
if ( !$p{no_changes} && $target && -e $target->plan_file && $target->plan->contains($arg) ) {
# A change.
push @{ $rec{changes} } => $arg;
} elsif ($config->get( key => "target.$arg.uri") || URI->new($arg)->isa('URI::db')) {
Expand Down
8 changes: 7 additions & 1 deletion t/command.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use warnings;
use 5.010;
use utf8;
use Test::More tests => 165;
use Test::More tests => 166;
#use Test::More 'no_plan';
use Test::NoWarnings;
use List::Util qw(first);
Expand Down Expand Up @@ -424,6 +424,12 @@ ARGS: {

is_deeply $parsem->(args => ['sqlite']), [['devdb'], []],
'Should resolve engine "sqlite" file to its target';

# Make sure we don't get an error when the default target has no plan file.
my $mock_target = Test::MockModule->new('App::Sqitch::Target');
$mock_target->mock(plan_file => file 'no-such-file.txt');
is_deeply $parsem->( args => ['devdb'] ), [['devdb'], []],
'Should recognize target when default target has no plan file';
}

##############################################################################
Expand Down

0 comments on commit 48c17b0

Please sign in to comment.