[Bps-public-commit] r15510 - sd/trunk/lib/App/SD/CLI/Command

jesse at bestpractical.com jesse at bestpractical.com
Wed Aug 27 02:27:07 EDT 2008


Author: jesse
Date: Wed Aug 27 02:27:06 2008
New Revision: 15510

Added:
   sd/trunk/lib/App/SD/CLI/Command/Log.pm

Log:
 * A slightly cleaner log command for sd

Added: sd/trunk/lib/App/SD/CLI/Command/Log.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Log.pm	Wed Aug 27 02:27:06 2008
@@ -0,0 +1,64 @@
+package App::SD::CLI::Command::Log;
+use Moose;
+extends 'Prophet::CLI::Command::Log';
+
+sub handle_changeset {
+    my $self      = shift;
+    my $changeset = shift;
+    print $changeset->as_string(
+        change_filter => sub {
+            my $change = shift;
+            return undef if $change->record_type eq '_merge_tickets';
+            return 1;
+        },
+        change_header => sub {
+            my $change = shift;
+            $self->change_header($change)."\n";
+        },
+        header_callback => sub {
+            my $c = shift;
+            sprintf "Change %d by %s at %s\n",
+                $c->sequence_no,
+                ( $c->creator || '(unknown)' ),
+                $c->created,
+                ;
+            }
+
+    );
+
+}
+
+
+sub change_header {
+    my $self   = shift;
+    my $change = shift;
+
+    if (my $sub = $self->can("change_header_".$change->record_type)) {
+        return $sub->($self, $change);
+    }
+
+    else {
+    return
+          " # "
+        . ucfirst($change->record_type) . " "
+        . $self->app_handle->handle->find_or_create_luid(
+        uuid => $change->record_uuid )
+        . " ("
+        . $change->record_uuid . ")";
+    }
+}
+
+sub change_header_ticket {
+    my $self = shift;
+    my $change = shift;
+    require App::SD::Model::Ticket;
+    my $t = App::SD::Model::Ticket->new( handle => $self->handle, type => App::SD::Model::Ticket->type);
+    $t->load(uuid => $change->record_uuid);
+    return " # Ticket "
+        . $self->app_handle->handle->find_or_create_luid(
+        uuid => $change->record_uuid )
+        . " (".$t->prop('summary').")"
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;



More information about the Bps-public-commit mailing list