]> git.mjollnir.org Git - cil.git/commitdiff
cil-b5a4ef93: Added VCS directives for 'add'
authorAndrew Chilton <andychilton@gmail.com>
Fri, 22 Jan 2010 02:08:34 +0000 (15:08 +1300)
committerAndrew Chilton <andychilton@gmail.com>
Fri, 22 Jan 2010 02:08:34 +0000 (15:08 +1300)
bin/cil
issues/c_da74ee18.cil [new file with mode: 0644]
issues/i_b5a4ef93.cil
lib/CIL/Base.pm
lib/CIL/Command/Add.pm
lib/CIL/VCS/Git.pm

diff --git a/bin/cil b/bin/cil
index 7c7d8b599cae137e6f169a6255fb91ad669079b4..6b579af49a616c18841e5dac4f9d9c440bcb236f 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -60,6 +60,8 @@ my @IN_OPTS = (
     'is-closed',    # for 'summary', 'list'
     'is-mine',      # for 'summary', 'list'
     'mine',         # for 'add'
+    'add',          # for 'add', 'comment'
+    'commit',       # for 'add', 'comment'
     'batch',        # for 'am'
     'help',
     'version',
@@ -73,6 +75,8 @@ my %BOOLEAN_ARGS = (
     'is-closed' => 1,
     'is-mine'   => 1,
     'mine'      => 1,
+    'add'       => 1,
+    'commit'    => 1,
     'batch'     => 1,
 );
 
diff --git a/issues/c_da74ee18.cil b/issues/c_da74ee18.cil
new file mode 100644 (file)
index 0000000..00d3fa7
--- /dev/null
@@ -0,0 +1,6 @@
+Issue: b5a4ef93
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2010-01-22T02:07:31
+Updated: 2010-01-22T02:07:47
+
+Added the code for --commit and --add for 'add'.
index bb454102329554395471e9d132559a49deef2e6d..731e1ea664e9c42983d1a4c81b83f66218057539 100644 (file)
@@ -1,10 +1,11 @@
 Summary: Add a '--commit' to 'cil add' (plus some others)
-Status: New
+Status: InProgress
 CreatedBy: Andrew Chilton <andychilton@gmail.com>
 AssignedTo: Andrew Chilton <andychilton@gmail.com>
 Label: Milestone-v0.06
+Comment: da74ee18
 Inserted: 2009-12-23T06:27:27
-Updated: 2010-01-21T22:59:19
+Updated: 2010-01-22T02:07:47
 
 When adding a new issue, I usually do:
 
index d911aae64abb5787eb4674384f700e6e6e98d1f9..e273e2cc09827f2c8e4002c0840ade14dafb2193 100644 (file)
@@ -38,7 +38,7 @@ sub new_from_name {
     croak 'provide a name'
         unless defined $name;
 
-    my $filename = $class->create_filename($cil, $name);
+    my $filename = $class->filename($cil, $name);
     croak "filename '$filename' does no exist"
         unless $cil->file_exists($filename);
 
@@ -115,7 +115,7 @@ sub set_data {
 sub save {
     my ($self, $cil) = @_;
 
-    my $filename = $self->create_filename($cil, $self->name);
+    my $filename = $self->filename($cil, $self->name);
 
     my $fields = $self->fields();
 
@@ -128,7 +128,7 @@ sub as_output {
     return CIL::Utils->format_data_as_output( $self->{data}, @$fields );
 }
 
-sub create_filename {
+sub filename {
     my ($class, $cil, $name) = @_;
 
     # create the filename from it's parts
index 18ff0bb22b32280d417fcc74da63e5d9365472a6..df15902cce84855b790aac4ecd44c661cb2b17cf 100644 (file)
@@ -45,7 +45,17 @@ sub run {
         if $args->{mine};
     $issue->Description("Description ...");
 
-    CIL::Utils->add_issue_loop($cil, undef, $issue);
+    $issue = CIL::Utils->add_issue_loop($cil, undef, $issue);
+
+    # if we want to add or commit this issue
+    if ( $args->{add} or $args->{commit} ) {
+        $cil->vcs->add( $cil, $issue );
+    }
+
+    # if we want to commit this issue
+    if ( $args->{commit} ) {
+        $cil->vcs->commit( $cil, $issue );
+    }
 }
 
 1;
index abc30fd5d317af33eea3f4d50045f99b7a873aab..bc048e8084f9c16ddb8c087c8df0b0129a5255f6 100644 (file)
@@ -108,6 +108,21 @@ sub create_branch {
     $self->git->command('checkout', '-b', $branch_name);
 }
 
+sub add {
+    my ($self, $cil, $entity) = @_;
+
+    my $filename = $entity->filename($cil, $entity->name());
+    return $self->git->command('add', $filename);
+}
+
+sub commit {
+    my ($self, $cil, $entity) = @_;
+
+    my $filename = $entity->filename($cil, $entity->name());
+    my $message = 'cil-' . $entity->name . ': New Issue';
+    return $self->git->command('commit', '-m', $message, $filename);
+}
+
 ## ----------------------------------------------------------------------------
 1;
 ## ----------------------------------------------------------------------------