Permalink
Browse files

Rename filter_in and filter_out to include_message and exclude_message.

  • Loading branch information...
1 parent f4110ec commit c513827d82c6bc1758d32cf4215913a4905ede0f @rcaputo committed Oct 11, 2012
Showing with 42 additions and 27 deletions.
  1. +42 −27 lib/Dist/Zilla/Plugin/ChangelogFromGit.pm
@@ -82,14 +82,14 @@ has earliest_date => (
},
);
-has filter_in => (
- is => 'ro',
- isa => 'Str',
+has include_message => (
+ is => 'ro',
+ isa => 'Str',
);
-has filter_out => (
- is => 'ro',
- isa => 'Str',
+has exclude_message => (
+ is => 'ro',
+ isa => 'Str',
);
sub gather_files {
@@ -167,16 +167,21 @@ sub gather_files {
warn ">>> $release_range\n" if $self->debug();
+ my $exclude_message_re = $self->exclude_message();
+ my $include_message_re = $self->include_message();
+
my $iter = Git::Repository::Log::Iterator->new($release_range);
while (my $log = $iter->next) {
- if($self->filter_out) {
- my $out_re = $self->filter_out();
- next if $log->message =~ /$out_re/;
- }
- if($self->filter_in){
- my $in_re = $self->filter_in();
- next unless $log->message =~ /$in_re/;
- }
+ next if (
+ defined $exclude_message_re and
+ $log->message() =~ /$exclude_message_re/o
+ );
+
+ next if (
+ defined $include_message_re and
+ $log->message() =~ /$include_message_re/o
+ );
+
#print STDERR "LOG: ".$log->message."\n";
warn(" ", $log->commit(), " ", $log->committer_localtime, "\n") if (
@@ -492,26 +497,36 @@ runtime tracing on STDERR.
[ChangelogFromGit]
debug = 1
-=head2 filter_out = REGULAR_EXPRESSION
+=head2 exclude_message = REGULAR_EXPRESSION
-C<filter_out> sets a regular expression which discards matching commit
-messages. This provides a way to exclude commit messages such as
-'forgot to include file X' or 'typo'.
+C<exclude_message> sets a regular expression which discards matching
+commit messages. This provides a way to exclude commit messages such
+as 'forgot to include file X' or 'typo'. The regular expression is
+case sensitive.
[ChangelogFromGit]
- filter_out = ^forgot
+ exclude_message = ^(forgot|typo)
+
+C<include_message> can be used to do the opposite: exclude all changes
+except ones that match a regular expression. Using both at once is
+liable to generate empty change logs.
-=head2 filter_in = REGULAR_EXPRESSION
+=head2 include_message = REGULAR_EXPRESSION
-C<filter_in> does the opposite of C<filter_out>: it sets a regular
-expression which commit messages must match in order to be included
-in the Changes file. This means that when making a commit whith a
-relevant message, you can include the regular expression pattern to
-have it included in the Changes file, and ignore all the irrelevant
-commit messages.
+C<include_message> does the opposite of C<exclude_message>: it sets a
+regular expression which commit messages must match in order to be
+included in the Changes file. This means that when making a commit
+with a relevant message, you must include text that matches the
+regular expression pattern to have it included in the Changes file.
+All other commit messages are ignored.
+
+The regular expression is case sensitive.
[ChangelogFromGit]
- filter_in = ^Major
+ include_message = ^Major
+
+Using both C<include_message> and C<exclude_message> at the same time
+will most likely result in empty change logs.
=head1 HOW IT WORKS

0 comments on commit c513827

Please sign in to comment.