| Line | |
|---|
| 1 | package ShipIt::Step::CommitMessageWrap; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use base 'ShipIt::Step'; |
|---|
| 5 | our $VERSION = '0.02'; |
|---|
| 6 | |
|---|
| 7 | sub init { |
|---|
| 8 | my ($self, $conf) = @_; |
|---|
| 9 | |
|---|
| 10 | $self->{format} = $conf->value('commit_message.format') || '%msg'; |
|---|
| 11 | $self->{format} =~ s/%/%%/g; |
|---|
| 12 | $self->{format} =~ s/%%msg/%s/g; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | sub run { |
|---|
| 16 | my ($self, $state) = @_; |
|---|
| 17 | |
|---|
| 18 | my $pkg = ref($state->vc); |
|---|
| 19 | |
|---|
| 20 | my $commit = $pkg->can('commit'); |
|---|
| 21 | my $tag_version = $pkg->can('tag_version'); |
|---|
| 22 | no strict 'refs'; |
|---|
| 23 | *{"$pkg\::commit"} = sub { |
|---|
| 24 | use strict; |
|---|
| 25 | my $c = shift; |
|---|
| 26 | my $msg = shift; |
|---|
| 27 | $msg = sprintf $self->{format}, $msg; |
|---|
| 28 | $commit->($c, $msg, @_); |
|---|
| 29 | }; |
|---|
| 30 | *{"$pkg\::tag_version"} = sub { |
|---|
| 31 | use strict; |
|---|
| 32 | my $c = shift; |
|---|
| 33 | my $ver = shift; |
|---|
| 34 | my $msg = shift; |
|---|
| 35 | $msg = sprintf $self->{format}, $msg; |
|---|
| 36 | $tag_version->($c, $ver, $msg, @_); |
|---|
| 37 | }; |
|---|
| 38 | use strict; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | 1; |
|---|
| 42 | __END__ |
|---|
| 43 | |
|---|
| 44 | =head1 NAME |
|---|
| 45 | |
|---|
| 46 | ShipIt::Step::CommitMessageWrap - commit message wrapping format to shipit version control |
|---|
| 47 | |
|---|
| 48 | =head1 SYNOPSIS |
|---|
| 49 | |
|---|
| 50 | None. |
|---|
| 51 | |
|---|
| 52 | =head1 DESCRIPTION |
|---|
| 53 | |
|---|
| 54 | this module is quick hack to commit and tag_version method in ShipIt::VC module. |
|---|
| 55 | commit message it makes your free wrapping format to version control. |
|---|
| 56 | |
|---|
| 57 | =head1 CONFIGURATION |
|---|
| 58 | |
|---|
| 59 | In the .shipit file: |
|---|
| 60 | |
|---|
| 61 | commit_message.format = before %msg after |
|---|
| 62 | |
|---|
| 63 | tagging log: |
|---|
| 64 | |
|---|
| 65 | before Tagging version '$ver' using shipit. after |
|---|
| 66 | |
|---|
| 67 | =head1 AUTHOR |
|---|
| 68 | |
|---|
| 69 | Kazuhiro Osawa E<lt>ko@yappo.ne.jpE<gt> |
|---|
| 70 | |
|---|
| 71 | =head1 SEE ALSO |
|---|
| 72 | |
|---|
| 73 | =head1 LICENSE |
|---|
| 74 | |
|---|
| 75 | This library is free software; you can redistribute it and/or modify |
|---|
| 76 | it under the same terms as Perl itself. |
|---|
| 77 | |
|---|
| 78 | =cut |
|---|