[Bps-public-commit] SD branch, master, updated. 0.74-43-gefaf967
Jesse Vincent
jesse at bestpractical.com
Tue Jul 6 03:18:51 EDT 2010
The branch, master has been updated
via efaf967772189b44bb4a82141ef2190f0cd67ccc (commit)
via 62b3400cbd304b2822d00e6b7a62f24f8c536fdb (commit)
via e30b0597a3be2b23c51aa75b18549f1181b7618c (commit)
via f43ff3c0023831a68d3ca3845d5fbc0bbda6061c (commit)
from e3ad8f6a9d2b60a27af7decac8c1465b8b024b88 (commit)
Summary of changes:
MANIFEST | 6 ++--
Makefile.PL | 2 +-
lib/App/SD/CLI.pm | 53 +++++++++++++++++++++++++++++++
lib/App/SD/CLI/Command/Log.pm | 21 ++++++++----
lib/App/SD/CLI/Command/Ticket/Review.pm | 2 +-
lib/App/SD/CLI/Command/Ticket/Show.pm | 44 +++++++++++++++++++------
t/06-ticket-show.t | 35 +++++++++++---------
t/sd-log.t | 31 +++++++++++-------
8 files changed, 143 insertions(+), 51 deletions(-)
- Log -----------------------------------------------------------------
commit f43ff3c0023831a68d3ca3845d5fbc0bbda6061c
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Sun Jul 4 18:11:37 2010 +0100
Typo fix
diff --git a/lib/App/SD/CLI/Command/Ticket/Review.pm b/lib/App/SD/CLI/Command/Ticket/Review.pm
index 1d64588..d290d59 100644
--- a/lib/App/SD/CLI/Command/Ticket/Review.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Review.pm
@@ -51,7 +51,7 @@ after out_record => sub {
foreach my $do ( @list ) {
my $action = $ACTIONS{ $do };
unless ( $action ) {
- print "No action binded to '$do', try again...\n";
+ print "No action bound to '$do', try again...\n";
$ask_again = 1; next;
}
next unless $action->{'action'};
commit e30b0597a3be2b23c51aa75b18549f1181b7618c
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Jul 5 18:37:25 2010 +0200
first past at a cli readability overhaul
diff --git a/Makefile.PL b/Makefile.PL
index cba8e52..75e5f87 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,7 +1,7 @@
use inc::Module::Install;
name('App-SD');
author('Jesse Vincent and Chia-Liang Kao');
-copyright('2008-2009 Best Practical Solutions, LLC');
+#copyright('2008-2009 Best Practical Solutions, LLC');
license('MIT');
version_from('lib/App/SD.pm');
diff --git a/lib/App/SD/CLI.pm b/lib/App/SD/CLI.pm
index 1c1a462..d9aae3a 100644
--- a/lib/App/SD/CLI.pm
+++ b/lib/App/SD/CLI.pm
@@ -12,6 +12,59 @@ has '+app_class' => (
sub dispatcher_class { "App::SD::CLI::Dispatcher" }
+sub format_change {
+ my $self = shift;
+ my %args = (
+ change => undef,
+ header_callback => undef,
+ @_
+ );
+ my $output = $args{header_callback} ? $args{header_callback}->( $args{change} ) : '' ;
+
+ if ( $args{change}->record_type eq 'comment' && $args{change}->change_type eq 'add_file' ) {
+ my $change = $args{change}->as_hash;
+
+ $output .= App::SD::CLI::Command::Ticket::Show->format_comment(
+ ( ( $change->{prop_changes}->{'content_type'} && $change->{prop_changes}->{'content_type'}->{new_value} )
+ ? $change->{prop_changes}->{'content_type'}->{new_value}
+ : 'text/plain'
+ ),
+ $change->{prop_changes}->{'content'}->{new_value}
+
+ );
+ } else {
+ if ( my @prop_changes = $args{change}->prop_changes ) {
+ $output .= $args{change_header}->( $args{change} ) if ( $args{change_header} );
+ $output .= App::SD::CLI->format_prop_changes( \@prop_changes );
+
+ }
+ }
+
+ return $output . "\n";
+
+}
+
+sub format_prop_changes {
+ my $self = shift;
+ my $prop_changes = shift;
+ my $output;
+ for (@$prop_changes) {
+ if ( defined $_->new_value && defined $_->old_value ) {
+ $output .= sprintf( "%18.18s", $_->name ) . ": changed from " . $_->old_value . " to " . $_->new_value;
+ } elsif ( defined $_->new_value ) {
+ $output .= sprintf( "%18.18s", $_->name ) . ": set to " . $_->new_value;
+
+ } elsif ( defined $_->old_value ) {
+ $output .= sprintf( "%18.18s", $_->name ) . ": " . $_->old_value . " deleted";
+ } else {
+ next;
+ }
+
+ $output .= "\n";
+ }
+ return $output;
+}
+
__PACKAGE__->meta->make_immutable;
no Any::Moose;
diff --git a/lib/App/SD/CLI/Command/Log.pm b/lib/App/SD/CLI/Command/Log.pm
index 4166518..2576ca2 100644
--- a/lib/App/SD/CLI/Command/Log.pm
+++ b/lib/App/SD/CLI/Command/Log.pm
@@ -2,6 +2,8 @@ package App::SD::CLI::Command::Log;
use Any::Moose;
extends 'Prophet::CLI::Command::Log';
+use App::SD::CLI::Command::Ticket::Show;
+
sub handle_changeset {
my $self = shift;
my $changeset = shift;
@@ -10,14 +12,21 @@ sub handle_changeset {
change_filter => sub {
my $change = shift;
return undef if $change->record_type eq '_merge_tickets';
+ if ($change->record_type eq 'comment') {
+ }
return 1;
},
+ change_formatter => sub {
+ App::SD::CLI->format_change(@_);
+ },
+
change_header => sub {
my $change = shift;
- $self->change_header($change)."\n";
+ $self->change_header($change)."\n".("-"x80)."\n";
},
header_callback => sub {
my $c = shift;
+ print "\n".("="x80) . "\n";
sprintf "%s - %s : %s@%s\n",
$c->created,
( $c->creator || '(unknown)' ),
@@ -30,7 +39,6 @@ sub handle_changeset {
}
-
sub change_header {
my $self = shift;
my $change = shift;
@@ -47,8 +55,7 @@ sub change_header_generic {
my $self = shift;
my $change = shift;
return
- " # "
- . ucfirst($change->record_type) . " "
+ ucfirst($change->record_type) . " "
. $self->app_handle->handle->find_or_create_luid(
uuid => $change->record_uuid )
. " ("
@@ -64,9 +71,9 @@ sub change_header_comment {
$c->load(uuid => $change->record_uuid);
if ($c->prop('ticket')) {
my $t = $c->ticket;
- return " # Comment on ticket " . $t->luid . " (".$t->prop('summary').")"
+ return "Comment on ticket " . $t->luid . " (".$t->prop('summary').")"
} else {
- return "# Comment on unknown ticket";
+ return "Comment on unknown ticket";
}
}
@@ -79,7 +86,7 @@ sub change_header_ticket {
unless ($t->uuid) {
return $self->change_header_generic($change);
}
- return " # Ticket "
+ return "Ticket "
. $self->app_handle->handle->find_or_create_luid(
uuid => $change->record_uuid )
. " (".($t->prop('summary')||'').")"
diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index 46c3fb0..a0e5d74 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -52,12 +52,10 @@ override run => sub {
print "\n= METADATA\n\n";
super();
-
my @history = sort by_creation_date ( @{ $record->comments }, $record->changesets );
my @attachments = sort by_creation_date @{ $record->attachments };
if (@attachments) {
- warn ref($_);
print "\n= ATTACHMENTS\n\n";
$self->show_attachment($_) for @attachments;
}
@@ -84,6 +82,17 @@ override run => sub {
};
+sub format_prop {
+ my $self = shift;
+ my $field = shift;
+ my $value = shift;
+ if ($self->has_arg('batch')) {
+ return "$field: $value\n";
+ } else {
+ return sprintf("%18.18s: %s\n",$field, $value);
+ }
+}
+
sub show_history_entry {
my $self = shift;
my $ticket = shift;
@@ -92,7 +101,8 @@ sub show_history_entry {
for my $change ( $changeset->changes ) {
next if $change->record_uuid ne $ticket->uuid;
- $body .= $change->as_string() ||next;
+
+ $body .= App::SD::CLI->format_change(change => $change) || next;
$body .= "\n";
}
@@ -116,17 +126,28 @@ sub show_attachment {
}
sub show_comment {
- my $self = shift;
+ my $self = shift;
my $comment = shift;
-
my $creator = $comment->prop('creator');
my $created = $comment->prop('created');
my $content_type = $comment->prop('content_type') || 'text/plain';
+ my $content = $comment->prop('content') || '';
my ($creation) = $comment->changesets(limit => 1);
- my $content = $comment->prop('content') || '';
+ $self->history_entry_header($creator,
+ $created,$creation->original_sequence_no, $self->app_handle->display_name_for_replica($creation->original_source_uuid));
+
+ print $self->format_comment($content_type, $content);
+ print "\n\n";
+}
+
+sub format_comment {
+ my $self = shift;
+ my $content_type = shift;
+ my $content = shift;
+
if ( $content_type =~ m{text/html}i ) {
$content =~ s|<p.*?>|\n|gismx;
@@ -138,21 +159,22 @@ sub show_comment {
$content =~ s|\n\n|\n|gismx;
}
- $self->history_entry_header($creator,
- $created,$creation->original_sequence_no, $self->app_handle->display_name_for_replica($creation->original_source_uuid));
- print $content;
- print "\n\n";
+ return $content;
}
sub history_entry_header {
my $self = shift;
my ($creator, $created, $sequence, $source) = (@_);
- printf "%s at %s\t\(%d@%s)\n\n",
+ print "="x80;
+ print "\n";
+ printf "%s at %s\t\(%d@%s)\n",
( $creator || '(unknown)' ),
$created,
$sequence,
$source;
+ print "-"x80;
+ print "\n";
}
__PACKAGE__->meta->make_immutable;
diff --git a/t/06-ticket-show.t b/t/06-ticket-show.t
index 8ffa11c..84e1ed0 100644
--- a/t/06-ticket-show.t
+++ b/t/06-ticket-show.t
@@ -34,28 +34,31 @@ TODO: {
'',
'= METADATA',
'',
- qr/^id:\s+$ticket_id \($ticket_uuid\)$/,
+ qr/id:\s+$ticket_id \($ticket_uuid\)$/,
qr/summary:\s+YATTA/,
qr/status:\s+new/,
qr/milestone:\s+alpha/,
qr/component:\s+core/,
- qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
- qr/^creator:\s+$ENV{PROPHET_EMAIL}$/,
+ qr/created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
+ qr/creator:\s+$ENV{PROPHET_EMAIL}$/,
qr/reporter:\s+$ENV{PROPHET_EMAIL}$/,
qr/original_replica:\s+$replica_uuid$/,
'',
'= HISTORY',
'',
- qr/^ $ENV{PROPHET_EMAIL} at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+\(\d+\@$replica_uuid\)$/,
- " + \"original_replica\" set to \"$replica_uuid\"",
- " + \"creator\" set to \"$ENV{PROPHET_EMAIL}\"",
- ' + "status" set to "new"',
- " + \"reporter\" set to \"$ENV{PROPHET_EMAIL}\"",
- qr/^ \+ "created" set to "\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"$/,
- ' + "component" set to "core"',
- ' + "summary" set to "YATTA"',
- ' + "milestone" set to "alpha"',
- '',
+ qr/^=+$/,
+ qr/$ENV{PROPHET_EMAIL} at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+\(\d+\@.*?\)$/,
+ qr/^-+$/,
+ qr/created: set to \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
+ qr/original_replica: set to $replica_uuid/,
+ qr/creator: set to $ENV{PROPHET_EMAIL}/,
+ qr/component: set to core/,
+ qr/summary: set to YATTA/,
+ qr/status: set to new/,
+ qr/milestone: set to alpha/,
+ qr/reporter: set to $ENV{PROPHET_EMAIL}/,
+ qr/^$/,
+ qr/^$/,
]
);
}
@@ -71,13 +74,13 @@ sub check_output_without_history {
'',
'= METADATA',
'',
- qr/^id:\s+$ticket_id \($ticket_uuid\)$/,
+ qr/id:\s+$ticket_id \($ticket_uuid\)$/,
qr'summary:\s+YATTA',
qr'status:\s+new',
qr'milestone:\s+alpha',
qr'component:\s+core',
- qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
- qr/^creator:\s+$ENV{PROPHET_EMAIL}$/,
+ qr/created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
+ qr/creator:\s+$ENV{PROPHET_EMAIL}$/,
qr/reporter:\s+$ENV{PROPHET_EMAIL}$/,
qr/original_replica:\s+$replica_uuid$/,
]
diff --git a/t/sd-gcode/basic.t b/t/sd-gcode/basic.t
index c29c3df..282781c 100644
--- a/t/sd-gcode/basic.t
+++ b/t/sd-gcode/basic.t
@@ -70,8 +70,8 @@ run_output_matches(
diag($err) if ($err);
diag($out);
-like( $out, qr/"content" set to "comment from sd"/, 'comment pushed' );
-like( $out, qr/"summary" set to "YATTA"/, 'ticket yatta pushed' );
+like( $out, qr/content set to comment from sd/i, 'comment pushed' );
+like( $out, qr/summary set to YATTA/i, 'ticket yatta pushed' );
unlike( $out, qr/test for sd/, 'pulled tickets not pushed' );
unlike( $out, qr/first comment.*second comment/s, 'pulled comments not pushed' );
diff --git a/t/sd-github/basic.t b/t/sd-github/basic.t
index 9ae1601..14eab68 100644
--- a/t/sd-github/basic.t
+++ b/t/sd-github/basic.t
@@ -61,8 +61,8 @@ run_output_matches(
diag($out);
diag($err);
-like( $out, qr/"content" set to "comment from sd"/, 'comment pushed' );
-like( $out, qr/"summary" set to "YATTA"/, 'ticket yatta pushed' );
+like( $out, qr/comment from sd/, 'comment pushed' );
+like( $out, qr/summary: set to YATTA/, 'ticket yatta pushed' );
unlike( $out, qr/test for sd/, 'pulled tickets not pushed' );
unlike( $out, qr/first comment.*second comment/s, 'pulled comments not pushed' );
diff --git a/t/sd-log.t b/t/sd-log.t
index 0cb0e4a..12b5fc3 100644
--- a/t/sd-log.t
+++ b/t/sd-log.t
@@ -24,18 +24,22 @@ my $replica_uuid = replica_uuid;
my ($log_id, $log_uuid) = create_ticket_ok( '--', 'summary', 'logs rock!');
# check the log
-run_output_matches_unordered( 'sd', [ 'log', 'LATEST' ],
+run_output_matches( 'sd', [ 'log', 'LATEST' ],
[
+ qr/^$/,
+ qr/^=+$/,
qr/^\d{4}-\d{2}-\d{2}.+ - $ENV{PROPHET_EMAIL} : \d+\@\Q$ENV{PROPHET_REPO}\E$/,
- qr/^ # Ticket \d+ \(logs rock!\)$/,
- ' + "original_replica" set to "'.$replica_uuid.'"',
- ' + "creator" set to "'.$ENV{PROPHET_EMAIL}.'"',
- ' + "status" set to "new"',
- ' + "reporter" set to "'.$ENV{PROPHET_EMAIL}.'"',
- qr/^ \+ "created" set to "\d{4}-\d{2}-\d{2}.+"$/,
- ' + "component" set to "core"',
- ' + "summary" set to "logs rock!"',
- ' + "milestone" set to "alpha"',
+ qr/^Ticket \d+ \(logs rock!\)$/,
+ qr/^-+$/,
+ qr/created: set to \d{4}-\d{2}-\d{2}.+/,
+ qr/original_replica: set to $replica_uuid/,
+ qr/creator: set to $ENV{PROPHET_EMAIL}/,
+ qr/component: set to core/,
+ qr/summary: set to logs rock!/,
+ qr/status: set to new/,
+ qr/milestone: set to alpha/,
+ qr/reporter: set to $ENV{PROPHET_EMAIL}/,
+ qr/^$/,
], [], "log output is correct",
);
# change a prop
@@ -49,9 +53,12 @@ run_output_matches( 'sd', [ 'ticket',
# check the log
run_output_matches( 'sd', [ 'log', 'LATEST' ],
[
+ '',
+ qr/^=+/,
qr/^\d{4}-\d{2}-\d{2}.+ - $ENV{PROPHET_EMAIL} : \d+\@\Q$ENV{PROPHET_REPO}\E$/,
- qr/^ # Ticket \d+ \(logs rock!\)$/,
- ' > "reporter" changed from "'.$ENV{PROPHET_EMAIL}.'" to "foo at bar.com".',
+ qr/^Ticket \d+ \(logs rock!\)$/,
+ qr/^-+/,
+ qr/reporter: changed from $ENV{PROPHET_EMAIL} to foo\@bar.com/,
'',
], [], "log output is correct",
);
commit 62b3400cbd304b2822d00e6b7a62f24f8c536fdb
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Jul 5 18:41:26 2010 +0200
MANIFEST fixes
diff --git a/MANIFEST b/MANIFEST
index 9219caa..b51e2c7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -172,6 +172,6 @@ t/sd-validation.t
t/server.t
tools/shipwright-package
tools/shipwright-package-minimal
-xt/00-dependencies.t
-xt/99-pod-coverage.t
-xt/99-pod.t
+xt/release/00-dependencies.t
+xt/release/99-pod-coverage.t
+xt/release/99-pod.t
commit efaf967772189b44bb4a82141ef2190f0cd67ccc
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Jul 6 09:20:05 2010 +0200
reverting incorrect test changes
diff --git a/t/sd-gcode/basic.t b/t/sd-gcode/basic.t
index 282781c..c29c3df 100644
--- a/t/sd-gcode/basic.t
+++ b/t/sd-gcode/basic.t
@@ -70,8 +70,8 @@ run_output_matches(
diag($err) if ($err);
diag($out);
-like( $out, qr/content set to comment from sd/i, 'comment pushed' );
-like( $out, qr/summary set to YATTA/i, 'ticket yatta pushed' );
+like( $out, qr/"content" set to "comment from sd"/, 'comment pushed' );
+like( $out, qr/"summary" set to "YATTA"/, 'ticket yatta pushed' );
unlike( $out, qr/test for sd/, 'pulled tickets not pushed' );
unlike( $out, qr/first comment.*second comment/s, 'pulled comments not pushed' );
diff --git a/t/sd-github/basic.t b/t/sd-github/basic.t
index 14eab68..9ae1601 100644
--- a/t/sd-github/basic.t
+++ b/t/sd-github/basic.t
@@ -61,8 +61,8 @@ run_output_matches(
diag($out);
diag($err);
-like( $out, qr/comment from sd/, 'comment pushed' );
-like( $out, qr/summary: set to YATTA/, 'ticket yatta pushed' );
+like( $out, qr/"content" set to "comment from sd"/, 'comment pushed' );
+like( $out, qr/"summary" set to "YATTA"/, 'ticket yatta pushed' );
unlike( $out, qr/test for sd/, 'pulled tickets not pushed' );
unlike( $out, qr/first comment.*second comment/s, 'pulled comments not pushed' );
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list