From: Andrew Chilton Date: Sat, 23 Jan 2010 13:07:01 +0000 (+1300) Subject: Lots of niceties fixed up to do with commit messages X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6f222726326c36065c092527f69bf45855a44fa5;p=cil.git Lots of niceties fixed up to do with commit messages --- diff --git a/lib/CIL/Command/Add.pm b/lib/CIL/Command/Add.pm index 0744254..dd1b147 100644 --- a/lib/CIL/Command/Add.pm +++ b/lib/CIL/Command/Add.pm @@ -54,7 +54,7 @@ sub run { # if we want to commit this issue if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $issue ); + $cil->vcs->commit( $cil, 'New Issue', $issue ); } } diff --git a/lib/CIL/Command/Comment.pm b/lib/CIL/Command/Comment.pm index 8bbf1e4..38288f9 100644 --- a/lib/CIL/Command/Comment.pm +++ b/lib/CIL/Command/Comment.pm @@ -53,7 +53,7 @@ sub run { # if we want to commit this comment if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $comment, $issue ); + $cil->vcs->commit( $cil, 'New Comment', $issue, $comment ); } } diff --git a/lib/CIL/Command/Edit.pm b/lib/CIL/Command/Edit.pm index f5dacc7..db53149 100644 --- a/lib/CIL/Command/Edit.pm +++ b/lib/CIL/Command/Edit.pm @@ -72,7 +72,7 @@ sub run { # if we want to commit this issue if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $issue ); + $cil->vcs->commit( $cil, 'Issue Edited', $issue ); } CIL::Utils->display_issue($cil, $issue); diff --git a/lib/CIL/Command/Label.pm b/lib/CIL/Command/Label.pm index 534a182..8687185 100644 --- a/lib/CIL/Command/Label.pm +++ b/lib/CIL/Command/Label.pm @@ -37,6 +37,8 @@ sub run { CIL::Utils->fatal("provide a valid label to add to this issue"); } + my @issues; + # for every issue foreach my $issue_name ( @issue_names ) { # firstly, read the issue in @@ -58,9 +60,16 @@ sub run { $cil->vcs->add( $cil, $issue ); } - # if we want to commit this issue - if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $issue ); + push @issues, $issue; + } + + # if we want to commit these issues + if ( $args->{commit} ) { + if ( $args->{remove} ) { + $cil->vcs->commit_multiple( $cil, "Removed label '$label'", @issues ); + } + else { + $cil->vcs->commit_multiple( $cil, "Added label '$label'", @issues ); } } } diff --git a/lib/CIL/Command/Status.pm b/lib/CIL/Command/Status.pm index 60d72d2..23212ef 100644 --- a/lib/CIL/Command/Status.pm +++ b/lib/CIL/Command/Status.pm @@ -37,6 +37,8 @@ sub run { CIL::Utils->fatal("provide a valid status to set this issue to"); } + my @issues; + # for every issue, read it it and set the Status foreach my $issue_name ( @issue_names ) { # firstly, read the issue in @@ -51,10 +53,12 @@ sub run { $cil->vcs->add( $cil, $issue ); } - # if we want to commit this issue - if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $issue ); - } + push @issues, $issue; + } + + # if we want to commit these issues + if ( $args->{commit} ) { + $cil->vcs->commit_multiple( $cil, "Status changed to '$status'", @issues ); } } diff --git a/lib/CIL/Command/Steal.pm b/lib/CIL/Command/Steal.pm index d86f549..e4d04f5 100644 --- a/lib/CIL/Command/Steal.pm +++ b/lib/CIL/Command/Steal.pm @@ -47,7 +47,7 @@ sub run { # if we want to commit this issue if ( $args->{commit} ) { - $cil->vcs->commit( $cil, $issue ); + $cil->vcs->commit( $cil, 'Issue Stolen', $issue ); } CIL::Utils->display_issue_full($cil, $issue); diff --git a/lib/CIL/VCS/Git.pm b/lib/CIL/VCS/Git.pm index c082bc4..091585b 100644 --- a/lib/CIL/VCS/Git.pm +++ b/lib/CIL/VCS/Git.pm @@ -120,7 +120,20 @@ sub add { } sub commit { - my ($self, $cil, @entities) = @_; + my ($self, $cil, $message, @entities) = @_; + + my @filenames; + foreach my $entity ( @entities ) { + my $filename = $entity->filename($cil, $entity->name()); + push @filenames, $filename; + } + + $message = 'cil-' . $entities[0]->name . ": $message"; + return $self->git->command('commit', '-m', $message, @filenames); +} + +sub commit_multiple { + my ($self, $cil, $message, @entities) = @_; my @filenames; foreach my $entity ( @entities ) { @@ -128,7 +141,6 @@ sub commit { push @filenames, $filename; } - my $message = 'cil-' . $entities[0]->name . ': New ' . $entities[0]->type; return $self->git->command('commit', '-m', $message, @filenames); }