]> git.mjollnir.org Git - cil.git/commitdiff
cil-5ec585b1: Now you can remove labels if you specify --remove to 'cil label'
authorAndrew Chilton <andychilton@gmail.com>
Sat, 23 Jan 2010 06:39:01 +0000 (19:39 +1300)
committerAndrew Chilton <andychilton@gmail.com>
Sat, 23 Jan 2010 06:39:01 +0000 (19:39 +1300)
bin/cil
issues/c_043f8971.cil [new file with mode: 0644]
issues/i_5ec585b1.cil
lib/CIL/Command/Label.pm
lib/CIL/Issue.pm

diff --git a/bin/cil b/bin/cil
index 6b579af49a616c18841e5dac4f9d9c440bcb236f..5a206ceb9f6288ec2df996dcf00d741e7f655fbd 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -63,6 +63,7 @@ my @IN_OPTS = (
     'add',          # for 'add', 'comment'
     'commit',       # for 'add', 'comment'
     'batch',        # for 'am'
+    'remove',       # for 'label'
     'help',
     'version',
 );
@@ -78,6 +79,7 @@ my %BOOLEAN_ARGS = (
     'add'       => 1,
     'commit'    => 1,
     'batch'     => 1,
+    'remove'    => 1,
 );
 
 ## ----------------------------------------------------------------------------
diff --git a/issues/c_043f8971.cil b/issues/c_043f8971.cil
new file mode 100644 (file)
index 0000000..d317428
--- /dev/null
@@ -0,0 +1,6 @@
+Issue: 5ec585b1
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2010-01-23T06:37:08
+Updated: 2010-01-23T06:37:20
+
+Now done. Should remove the correct label specified.
index c68fa96520c0428f6c5171becd86c6632822add0..caab41938aca7bc7b938663fff2dc84a6933276a 100644 (file)
@@ -1,12 +1,13 @@
 Summary: Add a cil label --remove command
-Status: New
+Status: Finished
 CreatedBy: Andrew Chilton <andychilton@gmail.com>
 AssignedTo: Andrew Chilton <andychilton@gmail.com>
 Label: Milestone-v0.06
+Comment: 043f8971
 Inserted: 2010-01-22T01:41:59
-Updated: 2010-01-22T01:43:31
+Updated: 2010-01-23T06:37:44
 
 Currently you can 'cil label MyLabel cafebabe' but you can't remove it. Add the
 following option:
 
- $ cil label --remote MyLabel cafebabe
+ $ cil label --remove MyLabel cafebabe
index 58f0e1c423663ba99e007a352d904aed43f52704..534a182ecd273eb6689b7a8d98bcc6cb71afe530 100644 (file)
@@ -37,13 +37,20 @@ sub run {
         CIL::Utils->fatal("provide a valid label to add to this issue");
     }
 
-    # for every issue, read it it and add the label
+    # for every issue
     foreach my $issue_name ( @issue_names ) {
         # firstly, read the issue in
         my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
 
-        # set the status for this issue
-        $issue->add_label( $label );
+        # decide whether we are adding or removing this label
+        if ( $args->{remove} ) {
+            $issue->remove_label( $label );
+        }
+        else {
+            $issue->add_label( $label );
+        }
+
+        # save
         $issue->save($cil);
 
         # if we want to add or commit this issue
index 77badac162b405f89e325143592e7b4a10fe24e8..75ca7b7d44e920c19d03d463521ef06153238cdd 100644 (file)
@@ -138,6 +138,17 @@ sub add_label {
     $self->flag_as_updated();
 }
 
+sub remove_label {
+    my ($self, $label) = @_;
+
+    croak 'provide a label when removing one'
+        unless defined $label;
+
+    # remove this label
+    @{$self->{data}{Label}} = grep { $_ ne $label } @{$self->{data}{Label}};
+    $self->flag_as_updated();
+}
+
 sub add_comment {
     my ($self, $comment) = @_;