root/lang/perl/ShipIt-Step-CommitMessageWrap/trunk/lib/ShipIt/Step/CommitMessageWrap.pm @ 3882

Revision 3882, 1.7 kB (checked in by yappo, 5 years ago)
Line 
1package ShipIt::Step::CommitMessageWrap;
2use strict;
3use warnings;
4use base 'ShipIt::Step';
5our $VERSION = '0.01';
6
7sub 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
15sub 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 $self = shift;
26        my $msg  = shift;
27warn "AAAAAAAAAAAAAAAAAAAAAAAAAAAA
28AAAAAAAAAAAAAAAAAA
29$msg
30SSSSSSSSSSSSSSSSSSSSSSSSSSSS
31SSSSSSSSSSSSSSSSSSSSS";
32        $msg = sprintf $self->{format}, $msg;
33        $commit->($self, $msg, @_);
34    };
35    *{"$pkg\::tag_version"} = sub {
36        use strict;
37        my $self = shift;
38        my $ver  = shift;
39        my $msg  = shift;
40        $msg = sprintf $self->{format}, $msg;
41        $commit->($self, $ver, $msg, @_);
42    };
43    use strict;
44}
45
461;
47__END__
48
49=head1 NAME
50
51ShipIt::Step::CommitMessageWrap - commit message wrapping format to shipit version control
52
53=head1 SYNOPSIS
54
55None.
56
57=head1 DESCRIPTION
58
59this module is quick hack to commit and tag_version method in ShipIt::VC module.
60commit message it makes your free wrapping format to version control.
61
62=head1 CONFIGURATION
63
64In the .shipit file:
65
66  commit_message.format = before %msg after
67
68tagging log:
69
70  before Tagging version '$ver' using shipit. after
71
72=head1 AUTHOR
73
74Kazuhiro Osawa E<lt>ko@yappo.ne.jpE<gt>
75
76=head1 SEE ALSO
77
78=head1 LICENSE
79
80This library is free software; you can redistribute it and/or modify
81it under the same terms as Perl itself.
82
83=cut
Note: See TracBrowser for help on using the browser.