From f46eba879d25e822c36190cba6dff67e9427cb0e Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Fri, 22 Jan 2010 15:08:34 +1300 Subject: [PATCH] cil-b5a4ef93: Added VCS directives for 'add' --- bin/cil | 4 ++++ issues/c_da74ee18.cil | 6 ++++++ issues/i_b5a4ef93.cil | 5 +++-- lib/CIL/Base.pm | 6 +++--- lib/CIL/Command/Add.pm | 12 +++++++++++- lib/CIL/VCS/Git.pm | 15 +++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 issues/c_da74ee18.cil diff --git a/bin/cil b/bin/cil index 7c7d8b5..6b579af 100755 --- 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 index 0000000..00d3fa7 --- /dev/null +++ b/issues/c_da74ee18.cil @@ -0,0 +1,6 @@ +Issue: b5a4ef93 +CreatedBy: Andrew Chilton +Inserted: 2010-01-22T02:07:31 +Updated: 2010-01-22T02:07:47 + +Added the code for --commit and --add for 'add'. diff --git a/issues/i_b5a4ef93.cil b/issues/i_b5a4ef93.cil index bb45410..731e1ea 100644 --- a/issues/i_b5a4ef93.cil +++ b/issues/i_b5a4ef93.cil @@ -1,10 +1,11 @@ Summary: Add a '--commit' to 'cil add' (plus some others) -Status: New +Status: InProgress CreatedBy: Andrew Chilton AssignedTo: Andrew Chilton 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: diff --git a/lib/CIL/Base.pm b/lib/CIL/Base.pm index d911aae..e273e2c 100644 --- a/lib/CIL/Base.pm +++ b/lib/CIL/Base.pm @@ -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 diff --git a/lib/CIL/Command/Add.pm b/lib/CIL/Command/Add.pm index 18ff0bb..df15902 100644 --- a/lib/CIL/Command/Add.pm +++ b/lib/CIL/Command/Add.pm @@ -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; diff --git a/lib/CIL/VCS/Git.pm b/lib/CIL/VCS/Git.pm index abc30fd..bc048e8 100644 --- a/lib/CIL/VCS/Git.pm +++ b/lib/CIL/VCS/Git.pm @@ -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; ## ---------------------------------------------------------------------------- -- 2.39.5