summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2013-01-30 16:19:50 -0600
committerNeil Moore <neil@s-z.org>2013-01-30 16:19:50 -0600
commit44a1ac03da277e887ecda672b14b905624bc3935 (patch)
tree079438617db71cf281056a3442c7244b56ee44c3
parenteb0db5d7c862cf92f1457dcfccfabc18f0353e76 (diff)
downloadcrawlbot-44a1ac03da277e887ecda672b14b905624bc3935.tar.gz
crawlbot-44a1ac03da277e887ecda672b14b905624bc3935.zip
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.
-rw-r--r--lib/Crawl/Bot/Plugin/Commit.pm9
1 files 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;
}