From c98f5e2d85be4b11224424e5df472ff10a4d2db9 Mon Sep 17 00:00:00 2001
From: Andrew Chilton <andychilton@gmail.com>
Date: Fri, 22 Jan 2010 15:12:37 +1300
Subject: [PATCH] cil-b5a4ef93: Added code for --commit and --add for the
 comment command

---
 issues/c_d98c9a37.cil      |  6 ++++++
 issues/i_b5a4ef93.cil      |  3 ++-
 lib/CIL/Command/Comment.pm | 17 +++++++++++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 issues/c_d98c9a37.cil

diff --git a/issues/c_d98c9a37.cil b/issues/c_d98c9a37.cil
new file mode 100644
index 0000000..6893a10
--- /dev/null
+++ b/issues/c_d98c9a37.cil
@@ -0,0 +1,6 @@
+Issue: b5a4ef93
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2010-01-22T02:11:30
+Updated: 2010-01-22T02:11:48
+
+Added the code for --add and --commit for 'comment'.
diff --git a/issues/i_b5a4ef93.cil b/issues/i_b5a4ef93.cil
index 731e1ea..f7074b7 100644
--- a/issues/i_b5a4ef93.cil
+++ b/issues/i_b5a4ef93.cil
@@ -3,9 +3,10 @@ Status: InProgress
 CreatedBy: Andrew Chilton <andychilton@gmail.com>
 AssignedTo: Andrew Chilton <andychilton@gmail.com>
 Label: Milestone-v0.06
+Comment: d98c9a37
 Comment: da74ee18
 Inserted: 2009-12-23T06:27:27
-Updated: 2010-01-22T02:07:47
+Updated: 2010-01-22T02:11:48
 
 When adding a new issue, I usually do:
 
diff --git a/lib/CIL/Command/Comment.pm b/lib/CIL/Command/Comment.pm
index d47f479..35a3c5e 100644
--- a/lib/CIL/Command/Comment.pm
+++ b/lib/CIL/Command/Comment.pm
@@ -31,7 +31,7 @@ use base qw(CIL::Command);
 sub name { 'comment' }
 
 sub run {
-    my ($self, $cil, undef, $issue_name) = @_;
+    my ($self, $cil, $args, $issue_name) = @_;
 
     my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
 
@@ -43,7 +43,20 @@ sub run {
     $comment->CreatedBy( CIL::Utils->user($cil) );
     $comment->Description("Description ...");
 
-    CIL::Utils->add_comment_loop($cil, undef, $issue, $comment);
+    $comment = CIL::Utils->add_comment_loop($cil, undef, $issue, $comment);
+
+    # if we want to add or commit this comment
+    if ( $args->{add} or $args->{commit} ) {
+        $cil->vcs->add( $cil, $issue );
+        $cil->vcs->add( $cil, $comment );
+    }
+
+    # if we want to commit this comment
+    if ( $args->{commit} ) {
+        $cil->vcs->commit( $cil, $issue );
+        $cil->vcs->commit( $cil, $comment );
+    }
+
 }
 
 1;
-- 
2.39.5