Fix getResponsibleAuthors

This commit is contained in:
Eelco Dolstra 2014-11-19 15:22:30 +01:00
parent 0d28e9372b
commit 7b5b434014

View file

@ -14,7 +14,7 @@ our @EXPORT = qw(
error notFound gone accessDenied error notFound gone accessDenied
forceLogin requireUser requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner forceLogin requireUser requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner
trim trim
getLatestFinishedEval getLatestFinishedEval getFirstEval
paramToList paramToList
backToReferer backToReferer
$pathCompRE $relPathRE $relNameRE $projectNameRE $jobsetNameRE $jobNameRE $systemRE $userNameRE $inputNameRE $pathCompRE $relPathRE $relNameRE $projectNameRE $jobsetNameRE $jobNameRE $systemRE $userNameRE $inputNameRE
@ -188,6 +188,14 @@ sub getLatestFinishedEval {
} }
sub getFirstEval {
my ($build) = @_;
return $build->jobsetevals->search(
{ hasnewbuilds => 1},
{ rows => 1, order_by => ["id"] })->single;
}
# Catalyst request parameters can be an array or a scalar or # Catalyst request parameters can be an array or a scalar or
# undefined, making them annoying to handle. So this utility function # undefined, making them annoying to handle. So this utility function
# always returns a request parameter as a list. # always returns a request parameter as a list.
@ -247,32 +255,35 @@ sub getResponsibleAuthors {
my ($build, $plugins) = @_; my ($build, $plugins) = @_;
my $prevBuild = getPreviousBuild($build); my $prevBuild = getPreviousBuild($build);
return ({}, 0, []) unless $prevBuild;
my $nrCommits = 0; my $nrCommits = 0;
my %authors; my %authors;
my @emailable_authors; my @emailable_authors;
if ($prevBuild) { my $prevEval = getFirstEval($prevBuild);
foreach my $curInput ($build->buildinputs_builds) { my $eval = getFirstEval($build);
next unless ($curInput->type eq "git" || $curInput->type eq "hg");
my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name });
next unless defined $prevInput;
next if $curInput->type ne $prevInput->type; foreach my $curInput ($eval->jobsetevalinputs) {
next if $curInput->uri ne $prevInput->uri; next unless ($curInput->type eq "git" || $curInput->type eq "hg");
next if $curInput->revision eq $prevInput->revision; my $prevInput = $prevEval->jobsetevalinputs->find({ name => $curInput->name });
next unless defined $prevInput;
my @commits; next if $curInput->type ne $prevInput->type;
foreach my $plugin (@{$plugins}) { next if $curInput->uri ne $prevInput->uri;
push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)}; next if $curInput->revision eq $prevInput->revision;
}
foreach my $commit (@commits) { my @commits;
#print STDERR "$commit->{revision} by $commit->{author}\n"; foreach my $plugin (@{$plugins}) {
$authors{$commit->{author}} = $commit->{email}; push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)};
push @emailable_authors, $commit->{email} if $curInput->emailresponsible; }
$nrCommits++;
} foreach my $commit (@commits) {
#print STDERR "$commit->{revision} by $commit->{author}\n";
$authors{$commit->{author}} = $commit->{email};
my $inputSpec = $build->jobset->jobsetinputs->find({ name => $curInput->name });
push @emailable_authors, $commit->{email} if $inputSpec && $inputSpec->emailresponsible;
$nrCommits++;
} }
} }