[Bps-public-commit] Prophet branch, master, updated. 90449f4372e48967413eef3a89e81c259a98a383

spang at bestpractical.com spang at bestpractical.com
Mon Aug 24 13:54:19 EDT 2009


The branch, master has been updated
       via  90449f4372e48967413eef3a89e81c259a98a383 (commit)
       via  690b28d21b43f0e5c670e9b95f73bd5310c1ad6b (commit)
       via  0187c5f3f53ecdf0528b5226f7a84a033e0d8e72 (commit)
       via  43888c5188d78fdfa410fcc76349e4d78358d350 (commit)
       via  5078515c237094e3d7efd97cba15f3ce4909189f (commit)
       via  03dc92fb72cad86acde3d1d64d385ac24d7ee1a4 (commit)
      from  ba73f7cb32f5d9457440e6d2a8d25080d1869965 (commit)

Summary of changes:
 lib/Prophet/CLI.pm                |   25 ++++++++++++++-----------
 lib/Prophet/CLI/Command/Config.pm |   17 ++++++++++-------
 lib/Prophet/CLI/Command/Init.pm   |    2 --
 lib/Prophet/Record.pm             |   25 +++++++++++++++++++------
 lib/Prophet/Server.pm             |    1 +
 t/search.t                        |   21 ++++++++++++++++++++-
 6 files changed, 64 insertions(+), 27 deletions(-)

- Log -----------------------------------------------------------------
commit 03dc92fb72cad86acde3d1d64d385ac24d7ee1a4
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 09:30:56 2009 +0100

    Remove some unused code

diff --git a/lib/Prophet/CLI/Command/Init.pm b/lib/Prophet/CLI/Command/Init.pm
index 04920ba..ab4e837 100644
--- a/lib/Prophet/CLI/Command/Init.pm
+++ b/lib/Prophet/CLI/Command/Init.pm
@@ -5,8 +5,6 @@ extends 'Prophet::CLI::Command';
 sub usage_msg {
     my $self = shift;
     my $cmd = $self->cli->get_script_name;
-    my $env_var = uc $cmd . '_REPO';
-    $env_var =~ s/ //;
 
     return <<"END_USAGE";
 usage: ${cmd}init

commit 5078515c237094e3d7efd97cba15f3ce4909189f
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 09:31:07 2009 +0100

    TODO comment

diff --git a/lib/Prophet/Server.pm b/lib/Prophet/Server.pm
index f12f8e6..99a9dd0 100644
--- a/lib/Prophet/Server.pm
+++ b/lib/Prophet/Server.pm
@@ -390,6 +390,7 @@ sub send_content {
 sub _send_401 {
     my $self = shift;
     print "HTTP/1.0 401 READONLY_SERVER\r\n";
+    # TODO give an actual error page?
     return '401';
 }
 

commit 43888c5188d78fdfa410fcc76349e4d78358d350
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 09:34:18 2009 +0100

    Clean up some bad formatting

diff --git a/lib/Prophet/CLI.pm b/lib/Prophet/CLI.pm
index 26191da..94d95f8 100644
--- a/lib/Prophet/CLI.pm
+++ b/lib/Prophet/CLI.pm
@@ -86,20 +86,21 @@ sub run_one_command {
     # find the first alias that matches, rerun the aliased cmd
     # note: keys of aliases are treated as regex, 
     # we need to substitute $1, $2 ... in the value if there's any
-
     my $ori_cmd = join ' ', @args;
 
-	if ($self->app_handle->local_replica_url) {
-    my $aliases = $self->app_handle->config->aliases;
-    for my $alias ( keys %$aliases ) {
-        my $command = $self->_command_matches_alias($ori_cmd, $alias, $aliases->{$alias}) || next;
-
-        # we don't want to recursively call if people stupidly write
-        # alias pull --local = pull --local
-        next if ( $command eq $ori_cmd );
-        return $self->run_one_command( split /\s+/, $command );
+    if ($self->app_handle->local_replica_url) {
+        my $aliases = $self->app_handle->config->aliases;
+        for my $alias ( keys %$aliases ) {
+            my $command = $self->_command_matches_alias(
+                $ori_cmd, $alias, $aliases->{$alias},
+            ) || next;
+
+            # we don't want to recursively call if people stupidly write
+            # alias pull --local = pull --local
+            next if ( $command eq $ori_cmd );
+            return $self->run_one_command( split /\s+/, $command );
+        }
     }
-	}
     #  really, we shouldn't be doing this stuff from the command dispatcher
     $self->context( Prophet::CLIContext->new( app_handle => $self->app_handle ) );
     $self->context->setup_from_args(@args);

commit 0187c5f3f53ecdf0528b5226f7a84a033e0d8e72
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 10:02:48 2009 +0100

    Fix a bug in the config/aliases parsing
    
    Closes: 2797c308-8dc1-11de-8001-d766e0f30323

diff --git a/lib/Prophet/CLI/Command/Config.pm b/lib/Prophet/CLI/Command/Config.pm
index 60a2692..fc50854 100644
--- a/lib/Prophet/CLI/Command/Config.pm
+++ b/lib/Prophet/CLI/Command/Config.pm
@@ -210,14 +210,15 @@ sub parse_cli_arg {
         $self->_setup_delete_subcmd( "$cmd delete", @args[1..$#args] );
     }
     # all of these may also contain add|set after alias
-    # prophet alias "foo bar" = "foo baz"
-    # prophet alias foo = bar
-    # prophet alias foo bar = bar baz
-    # prophet alias foo bar = "bar baz"
+    # prophet alias "foo bar" = "foo baz" (1)
+    # prophet alias foo = bar (1)
+    # prophet alias foo =bar (2)
+    # prophet alias foo bar = bar baz (1)
+    # prophet alias foo bar = "bar baz" (1)
     elsif ( $args[0] =~ /^(add|set)$/
-        || (@args >= 3 && grep { m/(^=|=$)/ } @args)
-        || (@args == 2 && $args[1] =~ /=/) ) {
-        my $subcmd = $1;
+        || (@args >= 3 && grep { m/^=|=$/ } @args)  # ex 1
+        || (@args == 2 && $args[1] =~ /^=|=$/) ) {  # ex 2
+        my $subcmd = defined $1 ? $1 : q{};
         shift @args if $args[0] =~ /^(?:add|set)$/;
 
         $self->_setup_old_syntax_add_subcmd( $cmd, $subcmd, @args );
@@ -304,6 +305,8 @@ sub _setup_old_syntax_add_subcmd {
         $self->context->set_arg(set => $args[0]);
     }
     else {
+        # the only way this will be triggered is if the user types
+        # "config add" or "config set"
         $self->print_usage(
             usage_method      => sub {
                 $self->add_usage_msg($cmd, $subcmd);

commit 690b28d21b43f0e5c670e9b95f73bd5310c1ad6b
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 17:25:16 2009 +0100

    Better error message when sprintf blows up formatting an atom
    
    printf format codes are arcane enough without having to guess why
    it's going wrong because our pager pipe obscured sprintf's warnings.

diff --git a/lib/Prophet/CLI.pm b/lib/Prophet/CLI.pm
index 94d95f8..8be043e 100644
--- a/lib/Prophet/CLI.pm
+++ b/lib/Prophet/CLI.pm
@@ -49,6 +49,8 @@ has interactive_shell => (
     default => 0,
 );
 
+# default line length for CLI-related things that ought to wrap
+use constant LINE_LENGTH => 80;
 
 =head2 _record_cmd
 
diff --git a/lib/Prophet/Record.pm b/lib/Prophet/Record.pm
index ff019d8..85dd505 100644
--- a/lib/Prophet/Record.pm
+++ b/lib/Prophet/Record.pm
@@ -743,11 +743,8 @@ array context, returns a list of
 sub format_summary {
     my $self = shift;
 
-    my @out = $self->_summary_format ?
-    $self->_parse_format_summary
-    : 
-    $self->_format_all_props_raw 
-    ;
+    my @out = $self->_summary_format ?  $self->_parse_format_summary
+                                     : $self->_format_all_props_raw;
     return @out if wantarray;
     return join ' ', map { $_->{formatted} } @out;
 }
@@ -814,6 +811,7 @@ sub atom_value {
 =head2 format_atom $string => $value
 
 Takes a format string / value pair and returns a formatted string for printing.
+Dies with a message if there's an error in the format string that sprintf warn()s on.
 
 =cut
 
@@ -821,7 +819,22 @@ sub format_atom {
     my $self = shift;
     my $string = shift;
     my $value = shift;
-    return sprintf($string, $self->atom_value($value));
+
+    my $formatted_atom;
+    eval {
+        use warnings FATAL => 'all';    # sprintf only warns on errors
+        $formatted_atom = sprintf($string, $self->atom_value($value));
+    };
+    if ( $@ ) {
+        chomp $@;
+        die "Error: cannot format value '".$self->atom_value($value)
+            ."' using atom '".$string."' in '".$self->type."' summary format\n\n"
+            ."Check that the ".$self->type.".summary-format config variable in your config\n"
+            ."file is valid. If this variable is not set, this is a bug in the default\n"
+            ."summary format for this ticket type.\n\n"
+            ."The error encountered was:\n\n'" . $@ . "'\n";
+    }
+    return $formatted_atom;
 }
 
 =head2 find_or_create_luid

commit 90449f4372e48967413eef3a89e81c259a98a383
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 18:29:17 2009 +0100

    Test for error message on invalid format atom

diff --git a/t/search.t b/t/search.t
index a58b202..cf88531 100644
--- a/t/search.t
+++ b/t/search.t
@@ -1,7 +1,8 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Prophet::Test tests => 17;
+use Prophet::Test tests => 18;
+use Prophet::Util;
 
 use_ok('Prophet::CLI::Command::Search');
 
@@ -81,5 +82,23 @@ as_alice {
     $out = run_command(qw(search --type Bug --regex=new -- status=~n));
     $expected = qr/first ticket summary/;
     like( $out, $expected, 'found a ticket with regex and props working together' );
+
+    my $broken_config_content = <<'END_CONFIG';
+[Bug]
+    summary-format = %,status
+END_CONFIG
+    Prophet::Util->write_file( file => $ENV{PROPHET_APP_CONFIG},
+        content => $broken_config_content );
+    my $expected_error = qr/Error: cannot format value 'new' using atom '%' in 'Bug' summary format
+
+Check that the Bug.summary-format config variable in your config
+file is valid. If this variable is not set, this is a bug in the default
+summary format for this ticket type.
+
+The error encountered was:
+
+'Invalid conversion in sprintf: end of string at/;
+     my (undef, $error) = run_command( qw(search --type Bug --regex .) );
+     like( $error, $expected_error, 'error on bad format atom' );
 };
 

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



More information about the Bps-public-commit mailing list