Skip to content

Commit

Permalink
Fix output verbosity for changes to be reverted
Browse files Browse the repository at this point in the history
Commit 06daffc changed the output of deploy and revert to also print
the changes to be deployed or reverted.  Changes to be deployed are
printed for verbosity > 1.  But changes to be reverted are printed for
verbosity > 0.  Fix that and require verbosity > 1 in both cases.
  • Loading branch information
ewie authored and theory committed Sep 2, 2023
1 parent b0fa313 commit 7d56f10
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Revision history for Perl extension App::Sqitch
that URI encoding works.
- Added notes on URL encoding database URLs to `sqitch-target.pod`, the
main reference for database URLs in the Sqitch documentation.
- Fixed the output of the list of changes to be deployed or reverted to
actually require `--verbose` twice, as described in the v1.4.0 changes,
and not just once. Thanks to Erik Wienhold for the PR (#785)!

1.4.0 2023-08-01T23:37:30Z
- Fixed Snowflake warehouse and role setup to properly quote identifiers
Expand Down
16 changes: 8 additions & 8 deletions lib/App/Sqitch/Engine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ sub revert {
change => $change->format_name_with_tags,
destination => $self->destination,
));
$sqitch->info(__ 'Will revert the following changes:');
map { $sqitch->info($_) } @change_descriptions;
$sqitch->debug(__ 'Will revert the following changes:');
map { $sqitch->debug($_) } @change_descriptions;
} else {
$sqitch->info(__ 'Would revert the following changes:');
map { $sqitch->info($_) } @change_descriptions;
$sqitch->debug(__ 'Would revert the following changes:');
map { $sqitch->debug($_) } @change_descriptions;
hurl {
ident => 'revert:confirm',
message => __ 'Nothing reverted',
Expand All @@ -400,11 +400,11 @@ sub revert {
'Reverting all changes from {destination}',
destination => $self->destination,
));
$sqitch->info(__ 'Will revert the following changes:');
map { $sqitch->info($_) } @change_descriptions;
$sqitch->debug(__ 'Will revert the following changes:');
map { $sqitch->debug($_) } @change_descriptions;
} else {
$sqitch->info(__ 'Would revert the following changes:');
map { $sqitch->info($_) } @change_descriptions;
$sqitch->debug(__ 'Would revert the following changes:');
map { $sqitch->debug($_) } @change_descriptions;
hurl {
ident => 'revert',
message => __ 'Nothing reverted',
Expand Down
39 changes: 25 additions & 14 deletions t/engine.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 => 775;
use Test::More tests => 780;
# use Test::More 'no_plan';
use App::Sqitch;
use App::Sqitch::Plan;
Expand Down Expand Up @@ -2050,6 +2050,7 @@ my @dbchanges;
$params;
} @changes[0..3];

MockOutput->clear;
MockOutput->ask_yes_no_returns(1);
is $engine->revert(undef, 1, 1), $engine, 'Revert all changes';
is_deeply $engine->seen, [
Expand Down Expand Up @@ -2077,12 +2078,14 @@ is_deeply +MockOutput->get_info_literal, [
[' - users @alpha ..', '.', ' '],
[' - roles ..', '........', ' '],
], 'It should have said it was reverting all changes and listed them';
is_deeply +MockOutput->get_info, [
is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
], 'Output should show what would be reverted';
is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
Expand Down Expand Up @@ -2114,12 +2117,14 @@ is_deeply +MockOutput->get_info_literal, [
[' - users @alpha ..', '.', ' '],
[' - roles ..', '........', ' '],
], 'It should have said it was reverting all changes and listed them';
is_deeply +MockOutput->get_info, [
is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
], 'Output should show what would be reverted';
is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
Expand All @@ -2142,13 +2147,13 @@ is_deeply +MockOutput->get_ask_yes_no, [
destination => $engine->destination,
), 1],
], 'Should have prompt to revert all changes';
is_deeply +MockOutput->get_info, [
is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
], 'It should have emitted nothing else';
], 'Output should show what would be reverted';

# Revert all changes with no prompt.
MockOutput->ask_yes_no_returns(1);
Expand Down Expand Up @@ -2180,16 +2185,18 @@ is_deeply +MockOutput->get_info, [
'Reverting all changes from {destination}',
destination => $engine->destination,
)],
[__ 'Will revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
], 'And the revert successes should be emitted';
is_deeply +MockOutput->get_debug, [
[__ 'Will revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
], 'Output should show what will be reverted';

# Now just revert to an earlier change.
$offset_change = $dbchanges[1];
Expand Down Expand Up @@ -2220,10 +2227,12 @@ is_deeply +MockOutput->get_info_literal, [
[' - lolz ..', '.........', ' '],
[' - widgets @beta ..', '', ' '],
], 'Output should show what it reverts to';
is_deeply +MockOutput->get_info, [
is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['widgets @beta'],
['lolz'],
], 'Output should show what would be reverted';
is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
], 'And the revert successes should be emitted';
Expand All @@ -2249,7 +2258,7 @@ is_deeply +MockOutput->get_ask_yes_no, [
destination => $engine->destination,
), 1],
], 'Should have prompt to revert to @alpha';
is_deeply +MockOutput->get_info, [
is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['widgets @beta'],
['lolz'],
Expand Down Expand Up @@ -2282,10 +2291,12 @@ is_deeply +MockOutput->get_info, [
destination => $engine->destination,
change => $dbchanges[-1]->format_name_with_tags,
)],
[__ 'Will revert the following changes:'],
['lolz'],
[__ 'ok'],
], 'And the header and "ok" should be emitted';
is_deeply +MockOutput->get_debug, [
[__ 'Will revert the following changes:'],
['lolz'],
], 'Output should show what will be reverted';

##############################################################################
# Test change_id_for_depend().
Expand Down

0 comments on commit 7d56f10

Please sign in to comment.