From 44a1ac03da277e887ecda672b14b905624bc3935 Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Wed, 30 Jan 2013 16:19:50 -0600 Subject: Avoid a useless (and ungrammatical) "... and 1 more commits" message. Printing that message is in many ways just as spammy as going ahead and printing the last commit. This means it's possible to go over announce_limit by one commit, but the total number of messages in one batch is still at most announce_limit + 1. --- lib/Crawl/Bot/Plugin/Commit.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Crawl/Bot/Plugin/Commit.pm b/lib/Crawl/Bot/Plugin/Commit.pm index 0189886..57cccbe 100644 --- a/lib/Crawl/Bot/Plugin/Commit.pm +++ b/lib/Crawl/Bot/Plugin/Commit.pm @@ -16,6 +16,9 @@ has announce_commits => ( default => 1, ); +# Maximum number of commits to announce from a large batch. If there +# are exactly announce_limits + 1 new commits, all of them will be +# announced, to avoid a useless "and 1 more commit" message. has announce_limit => ( is => 'rw', isa => 'Int', @@ -169,11 +172,13 @@ sub tick { $cherry_picks -= @revs; my $pl = $cherry_picks == 1 ? "" : "s"; $self->say_all("Cherry-picked $cherry_picks commit$pl into $branch") - if $cherry_picks > 0; + if $cherry_picks > 0; my $count = 0; for my $rev (reverse @revs) { - if (++$count > $self->announce_limit) { + # If it's just one more than the announce limit, don't bother with + # the message and announce the last commit anyway. + if (++$count > $self->announce_limit and scalar @revs > 1) { $self->say_all("... and " . (scalar @revs - $count + 1) . " more commits"); last; } -- cgit v1.2.3