From 83e732918b9e168605656f7a8d4096763d97c69a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 8 Jun 2016 21:54:49 -0700 Subject: [PATCH] taskd.pl: compute prior heads state and pass to Notify::ref_changes By providing the state of all the refs/heads/... values immediately prior to the current batch of ref changes, a much better job can be done selecting which revisions are actually new and which have been seen before. Signed-off-by: Kyle J. McKay --- taskd/taskd.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/taskd/taskd.pl b/taskd/taskd.pl index b375158..a40cfb2 100755 --- a/taskd/taskd.pl +++ b/taskd/taskd.pl @@ -706,9 +706,19 @@ sub ref_changes { } my @changes = (); + my %oldheads = (); + my %deletedheads = (); while (my $change = ) { my ($oldrev, $newrev, $ref) = split(/\s+/, $change); $oldrev =~ /^[0-9a-f]{40}$/ && $newrev =~ /^[0-9a-f]{40}$/ && $ref =~ m{^refs/} or next; + if ($ref =~ m{^refs/heads/.}) { + if ($oldrev =~ /^0{40}$/) { + delete $oldheads{$ref}; + $deletedheads{$ref} = 1; + } elsif ($newrev ne $oldrev || (!exists($oldheads{$ref}) && !$deletedheads{$ref})) { + $oldheads{$ref} = $oldrev; + } + } $newrev ne $oldrev or next; push(@changes, [$oldrev, $newrev, $ref]); } @@ -722,7 +732,7 @@ sub ref_changes { sleep 1 if $ran_mail_sh || $ran_git; }; if ($has_notify) { - Girocco::Notify::ref_changes($proj, $user, $statproc, @changes); + Girocco::Notify::ref_changes($proj, $user, $statproc, \%oldheads, @changes); } else { &$statproc(@$_) foreach @changes; } -- 2.11.4.GIT