[Bps-public-commit] SD branch, master, updated. 0a38d002f7e4b21951e9f1495cae3f9cd6f44533

jesse jesse at bestpractical.com
Thu Jun 11 12:52:37 EDT 2009


The branch, master has been updated
       via  0a38d002f7e4b21951e9f1495cae3f9cd6f44533 (commit)
       via  a850853c1c52c294f328c34400a4bd9087dd23d5 (commit)
      from  65a2364e0b9467094d9f244eac7780a0f5c30d13 (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Ticket/Show.pm |  133 ++++++++++++++++++++-------------
 1 files changed, 80 insertions(+), 53 deletions(-)

- Log -----------------------------------------------------------------
commit a850853c1c52c294f328c34400a4bd9087dd23d5
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 11:51:07 2009 -0400

    perltidy

diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index f94a8b9..3e9a8b3 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -12,7 +12,7 @@ sub ARG_TRANSLATIONS {
         b => 'batch';
 }
 
-sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
+sub by_creation_date { $a->prop('created') cmp $b->prop('created') }
 
 override run => sub {
     my $self = shift;
@@ -23,21 +23,20 @@ override run => sub {
     # prophet uses --verbose to decide whether to show all declared props
     # or not (rather than just the ones returned by props_to_show),
     # but --all-props is more consistent with sd's behaviour in update/create
-    if ($self->has_arg('all-props')) {
-        $self->set_arg('verbose' => 1);
+    if ( $self->has_arg('all-props') ) {
+        $self->set_arg( 'verbose' => 1 );
     }
 
     print "\n= METADATA\n\n";
     super();
 
-    my @attachments = sort by_creation_date @{$record->attachments};
+    my @attachments = sort by_creation_date @{ $record->attachments };
     if (@attachments) {
         print "\n= ATTACHMENTS\n\n";
-        $self->show_attachment($_)
-            for @attachments;
+        $self->show_attachment($_) for @attachments;
     }
 
-    my @comments = sort by_creation_date @{$record->comments};
+    my @comments = sort by_creation_date @{ $record->comments };
     if (@comments) {
         print "\n= COMMENTS\n\n";
         for my $comment (@comments) {
@@ -50,62 +49,62 @@ override run => sub {
     # allow user to not display history by specifying the --skip-history
     # arg or setting disable_ticket_show_history_by_default config item to a
     # true value (can be overridden with --with-history)
-    if (!$self->has_arg('skip-history') && (!$self->app_handle->config->get(
-                'disable_ticket_show_history_by_default') ||
-            $self->has_arg('with-history'))) {
+    if (!$self->has_arg('skip-history')
+        && (  !$self->app_handle->config->get('disable_ticket_show_history_by_default')
+            || $self->has_arg('with-history') )
+        )
+    {
         print "\n= HISTORY\n\n";
-        foreach my $changeset ($record->changesets) {
-            $self->show_history_entry($record, $changeset);
+        foreach my $changeset ( $record->changesets ) {
+            $self->show_history_entry( $record, $changeset );
         }
     }
 };
 
 sub show_history_entry {
-    my $self = shift;
-    my $ticket = shift;
+    my $self      = shift;
+    my $ticket    = shift;
     my $changeset = shift;
-    my $out ='';
-        $out .= $changeset->as_string(change_filter => sub {
-            $ticket->uuid eq $self->uuid
-        });
+    my $out       = '';
+    $out .= $changeset->as_string(
+        change_filter => sub {
+            $ticket->uuid eq $self->uuid;
+        }
+    );
     print $out;
 }
 
-
-
-
 sub show_attachment {
-    my $self = shift;
-   my $attachment = shift; 
-        print $attachment->format_summary . "\n"
+    my $self       = shift;
+    my $attachment = shift;
+    print $attachment->format_summary . "\n";
 }
 
-
 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') || '';
-            if ($content_type =~ m{text/html}i ){
-
-                $content =~ s|<p.*?>|\n|gismx;
-                $content =~ s|</?pre.*?>|\n|gismx;
-                $content =~ s|</?b\s*>|*|gismx;
-                $content =~ s|</?i\s*>|_|gismx;
-                $content =~ s|<a(?:.*?)href="(.*?)".*?>(.*?)</a.*?>|$2 [link: $1 ]|gismx;
-                $content =~ s|<.*?>||gismx;
-                $content =~ s|\n\n|\n|gismx;
-            }
-
-            print "$creator: " if $creator;
-            print "$created\n";
-            print $content;
-            print "\n\n";
-        }
+    my $creator      = $comment->prop('creator');
+    my $created      = $comment->prop('created');
+    my $content_type = $comment->prop('content_type') || 'text/plain';
+
+    my $content = $comment->prop('content') || '';
+    if ( $content_type =~ m{text/html}i ) {
+
+        $content =~ s|<p.*?>|\n|gismx;
+        $content =~ s|</?pre.*?>|\n|gismx;
+        $content =~ s|</?b\s*>|*|gismx;
+        $content =~ s|</?i\s*>|_|gismx;
+        $content =~ s|<a(?:.*?)href="(.*?)".*?>(.*?)</a.*?>|$2 [link: $1 ]|gismx;
+        $content =~ s|<.*?>||gismx;
+        $content =~ s|\n\n|\n|gismx;
+    }
+
+    print "$creator: " if $creator;
+    print "$created\n";
+    print $content;
+    print "\n\n";
+}
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

commit 0a38d002f7e4b21951e9f1495cae3f9cd6f44533
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 12:52:15 2009 -0400

    Make ticket history unified when using ticket show. (inline comments and other updates)

diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index 3e9a8b3..b3f9090 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -12,7 +12,13 @@ sub ARG_TRANSLATIONS {
         b => 'batch';
 }
 
-sub by_creation_date { $a->prop('created') cmp $b->prop('created') }
+sub by_creation_date { 
+    ($a->can('created') ? $a->created : $a->prop('created') )
+    cmp 
+    ($b->can('created') ? $b->created : $b->prop('created') )
+
+
+}
 
 override run => sub {
     my $self = shift;
@@ -30,22 +36,15 @@ 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;
     }
 
-    my @comments = sort by_creation_date @{ $record->comments };
-    if (@comments) {
-        print "\n= COMMENTS\n\n";
-        for my $comment (@comments) {
-
-            $self->show_comment($comment);
-
-        }
-    }
-
     # allow user to not display history by specifying the --skip-history
     # arg or setting disable_ticket_show_history_by_default config item to a
     # true value (can be overridden with --with-history)
@@ -55,23 +54,38 @@ override run => sub {
         )
     {
         print "\n= HISTORY\n\n";
-        foreach my $changeset ( $record->changesets ) {
-            $self->show_history_entry( $record, $changeset );
+        foreach my $item (@history) {
+            if ( $item->isa('Prophet::ChangeSet') ) {
+                $self->show_history_entry( $record, $item );
+            } elsif ( $item->isa('App::SD::Model::Comment') ) {
+                $self->show_comment($item);
+            }
         }
     }
-};
+    };
+
 
 sub show_history_entry {
     my $self      = shift;
     my $ticket    = shift;
     my $changeset = shift;
-    my $out       = '';
-    $out .= $changeset->as_string(
-        change_filter => sub {
-            $ticket->uuid eq $self->uuid;
-        }
-    );
-    print $out;
+    my $body = '';
+    
+    for my $change ( $changeset->changes ) {
+        next if $change->record_uuid ne $ticket->uuid;
+        $body .= $change->as_string() ||next;
+        $body .= "\n";
+    }
+
+    return '' if !$body;
+
+    $self->history_entry_header(
+         $changeset->creator,
+        $changeset->created,
+        $changeset->original_sequence_no,
+        $changeset->original_source_uuid);
+
+    print $body;
 }
 
 sub show_attachment {
@@ -88,6 +102,9 @@ sub show_comment {
     my $created      = $comment->prop('created');
     my $content_type = $comment->prop('content_type') || 'text/plain';
 
+
+    my ($creation) = $comment->changesets(limit => 1);
+
     my $content = $comment->prop('content') || '';
     if ( $content_type =~ m{text/html}i ) {
 
@@ -100,11 +117,22 @@ sub show_comment {
         $content =~ s|\n\n|\n|gismx;
     }
 
-    print "$creator: " if $creator;
-    print "$created\n";
+    $self->history_entry_header($creator, $created,$creation->original_sequence_no, $creation->original_source_uuid);
     print $content;
     print "\n\n";
 }
+
+
+sub history_entry_header {
+    my $self = shift;
+    my ($creator, $created, $sequence, $source) = (@_);
+     printf "%s at %s\t\(%d@%s)\n\n",
+        ( $creator || '(unknown)' ),
+        $created,
+        $sequence,
+        $source;
+    }
+
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list