Permalink
Browse files

Tweak changes and tags display.

Both need a leading empty line, so we can remove the special checking for
showing tags in `emit_changes()`, which is nice. Also, remove the bullets --
since the data is displayed as a table, it looks better without them.
  • Loading branch information...
1 parent dafb533 commit 445d4175549604c3f40061ebd748048fced315af @theory committed Jul 6, 2012
Showing with 26 additions and 37 deletions.
  1. +4 −5 lib/App/Sqitch/Command/status.pm
  2. +22 −32 t/status.t
@@ -132,6 +132,7 @@ sub emit_changes {
# Emit the header.
my @changes = $self->engine->current_changes;
+ $self->comment('');
$self->comment(__n 'Change:', 'Changes:', @changes);
# Find the longest change name.
@@ -140,25 +141,23 @@ sub emit_changes {
# Emit each change.
$self->comment(sprintf(
- ' * %s%s - %s - %s',
+ ' %s%s - %s - %s',
$_->{change},
((' ') x ($len - length $_->{change})) || '',
$_->{deployed_at}->as_string( format => $format ),
$_->{deployed_by},
)) for @changes;
- # Add a space if we will also be showing tags.
- $self->comment('') if $self->show_tags;
return $self;
}
sub emit_tags {
my $self = shift;
return $self unless $self->show_tags;
- return $self unless $self->show_changes;
# Emit the header.
my @tags = $self->engine->current_tags;
+ $self->comment('');
$self->comment(__n 'Tag:', 'Tags:', @tags);
# Find the longest tag name.
@@ -167,7 +166,7 @@ sub emit_tags {
# Emit each tag.
$self->comment(sprintf(
- ' * %s%s - %s - %s',
+ ' %s%s - %s - %s',
$_->{tag},
((' ') x ($len - length $_->{tag})) || '',
$_->{applied_at}->as_string( format => $format ),
View
@@ -3,7 +3,7 @@
use strict;
use warnings;
use utf8;
-use Test::More tests => 60;
+use Test::More tests => 57;
#use Test::More 'no_plan';
use App::Sqitch;
use Locale::TextDomain qw(App-Sqitch);
@@ -139,7 +139,7 @@ ok $status = App::Sqitch::Command->load({
config => $config,
}), 'Create status command with an engine';
-ok $status->emit_changes, 'Emit changes';
+ok $status->emit_changes, 'Try to emit changes';
is_deeply +MockOutput->get_comment, [],
'Should have emitted no changes';
@@ -150,8 +150,9 @@ ok $status = App::Sqitch::Command::status->new(
ok $status->emit_changes, 'Emit changes again';
is_deeply +MockOutput->get_comment, [
+ [''],
[__n 'Change:', 'Changes:', 1],
- [" * foo - $ts - anna"],
+ [" foo - $ts - anna"],
], 'Should have emitted one change';
# Add a couple more changes.
@@ -172,27 +173,13 @@ push @current_changes => (
ok $status->emit_changes, 'Emit changes thrice';
is_deeply +MockOutput->get_comment, [
+ [''],
[__n 'Change:', 'Changes:', 3],
- [" * foo - $ts - anna"],
- [" * blech - $ts - david"],
- [" * long_name - $ts - julie"],
+ [" foo - $ts - anna"],
+ [" blech - $ts - david"],
+ [" long_name - $ts - julie"],
], 'Should have emitted three changes';
-# Now set it up to emit tags, too.
-ok $status = App::Sqitch::Command::status->new(
- sqitch => $sqitch,
- show_changes => 1,
- show_tags => 1,
-), 'Create change-and-tag-showing status command';
-ok $status->emit_changes, 'Emit changes thrice';
-is_deeply +MockOutput->get_comment, [
- [__n 'Change:', 'Changes:', 3],
- [" * foo - $ts - anna"],
- [" * blech - $ts - david"],
- [" * long_name - $ts - julie"],
- [''],
-], 'Should have emitted three changes and a blank line';
-
##############################################################################
# Test emit_tags().
my @current_tags;
@@ -204,10 +191,19 @@ $engine_mocker->mock(current_tags => sub { @current_tags });
applied_at => $dt,
});
+ok $status->emit_tags, 'Try to emit tags';
+is_deeply +MockOutput->get_comment, [], 'No tags should have been emitted';
+
+ok $status = App::Sqitch::Command::status->new(
+ sqitch => $sqitch,
+ show_tags => 1,
+), 'Create tag-showing status command';
+
ok $status->emit_tags, 'Emit tags';
is_deeply +MockOutput->get_comment, [
+ [''],
[__n 'Tag:', 'Tags:', 1],
- [" * \@alpha - $ts - duncan"],
+ [" \@alpha - $ts - duncan"],
], 'Should have emitted one tag';
# Add a couple more tags.
@@ -228,19 +224,13 @@ push @current_tags => (
ok $status->emit_tags, 'Emit tags again';
is_deeply +MockOutput->get_comment, [
+ [''],
[__n 'Tag:', 'Tags:', 3],
- [" * \@alpha - $ts - duncan"],
- [" * \@beta - $ts - nick"],
- [" * \@gamma - $ts - jacqueline"],
+ [" \@alpha - $ts - duncan"],
+ [" \@beta - $ts - nick"],
+ [" \@gamma - $ts - jacqueline"],
], 'Should have emitted all three tags';
-# Turn off tag showing.
-ok $status = App::Sqitch::Command::status->new( sqitch => $sqitch ),
- 'Create now-change-or-tag status command';
-
-ok $status->emit_tags, 'Try to emit tags again';
-is_deeply +MockOutput->get_comment, [], 'No tags should have been emitted';
-
##############################################################################
# Test emit_status().
my $file = file qw(t plans multi.plan);

0 comments on commit 445d417

Please sign in to comment.