'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',
'is-closed' => 1,
'is-mine' => 1,
'mine' => 1,
+ 'add' => 1,
+ 'commit' => 1,
'batch' => 1,
);
--- /dev/null
+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'.
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:
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);
sub save {
my ($self, $cil) = @_;
- my $filename = $self->create_filename($cil, $self->name);
+ my $filename = $self->filename($cil, $self->name);
my $fields = $self->fields();
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
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;
$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;
## ----------------------------------------------------------------------------