From: Andrew Chilton Date: Fri, 22 Jan 2010 01:40:23 +0000 (+1300) Subject: cil-bf35f2c7: Now doesn't add duplicates X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=417ac3ad001cebb9e441a34db9b0f1d145c96385;p=cil.git cil-bf35f2c7: Now doesn't add duplicates --- diff --git a/issues/i_bf35f2c7.cil b/issues/i_bf35f2c7.cil index f5acc53..a61a59f 100644 --- a/issues/i_bf35f2c7.cil +++ b/issues/i_bf35f2c7.cil @@ -1,10 +1,10 @@ Summary: Adding a label twice actually does it -Status: New +Status: Finished CreatedBy: Andrew Chilton AssignedTo: Andrew Chilton Label: Milestone-v0.06 Inserted: 2009-12-05T00:38:49 -Updated: 2010-01-21T22:59:19 +Updated: 2010-01-22T01:39:51 Take an issue with no labels: diff --git a/lib/CIL/Issue.pm b/lib/CIL/Issue.pm index eff317f..77badac 100644 --- a/lib/CIL/Issue.pm +++ b/lib/CIL/Issue.pm @@ -131,6 +131,9 @@ sub add_label { croak 'provide a label when adding one' unless defined $label; + # return if we already have this label + return if grep { $_ eq $label } @{$self->{data}{Label}}; + push @{$self->{data}{Label}}, $label; $self->flag_as_updated(); }