[Bps-public-commit] r14514 - in Prophet/trunk: . lib/Prophet/CLI/Command

sartak at bestpractical.com sartak at bestpractical.com
Fri Jul 25 07:04:03 EDT 2008


Author: sartak
Date: Fri Jul 25 07:04:03 2008
New Revision: 14514

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Search.pm
   Prophet/trunk/t/search.t

Log:
 r65201 at onn:  sartak | 2008-07-25 06:36:24 -0400
 Support for "status=new" "status=open" being ORed together, not ANDed


Modified: Prophet/trunk/lib/Prophet/CLI/Command/Search.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	Fri Jul 25 07:04:03 2008
@@ -19,14 +19,23 @@
                 return 0;
             }
     } elsif (scalar $self->prop_names > 0) {
-        my @expected = $self->prop_set;
+        my %prop_checks;
+        for my $check ($self->prop_set) {
+            push @{ $prop_checks{ $check->{name} } }, $check;
+        }
+
         return sub {
             my $item = shift;
             my $props = $item->get_props;
 
-            for (@expected) {
-                my $got = $props->{ $_->{name} };
-                return 0 unless $self->cmp_ok($_->{value}, $_->{cmp}, $got);
+            for my $prop (keys %prop_checks) {
+                my $got = $props->{$prop};
+                my $ok = 0;
+                for my $check (@{ $prop_checks{$prop} }) {
+                    $ok = 1
+                        if $self->cmp_ok($check->{value}, $check->{cmp}, $got);
+                }
+                return 0 if !$ok;
             }
 
             return 1;

Modified: Prophet/trunk/t/search.t
==============================================================================
--- Prophet/trunk/t/search.t	(original)
+++ Prophet/trunk/t/search.t	Fri Jul 25 07:04:03 2008
@@ -30,13 +30,10 @@
         "found no tickets with status=closed",
     );
 
-    TODO: {
-        local $TODO = "props are stored in a flat hash, so we can't do OR yet";
-        run_output_matches('prophet', [qw(search --type Bug -- status=new status=open)],
-            [qr/first ticket summary/, qr/other ticket summary/],
-            "found two tickets with status=new OR status=open",
-        );
-    };
+    run_output_matches('prophet', [qw(search --type Bug -- status=new status=open)],
+        [qr/first ticket summary/, qr/other ticket summary/],
+        "found two tickets with status=new OR status=open",
+    );
 
     run_output_matches('prophet', [qw(search --type Bug -- status!=new)],
         [qr/other ticket summary/, qr/bad ticket summary/],



More information about the Bps-public-commit mailing list