Check all inputs for blame but only email selected inputs

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-10-08 14:47:24 -04:00
parent 804617f075
commit 26470f1656
11 changed files with 28 additions and 47 deletions

View file

@ -206,7 +206,6 @@ sub updateJobset {
, nixexprinput => $nixExprInput , nixexprinput => $nixExprInput
, enabled => $enabled ? 1 : 0 , enabled => $enabled ? 1 : 0
, enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0 , enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0
, emailresponsible => defined $c->stash->{params}->{emailresponsible} ? 1 : 0
, emailoverride => trim($c->stash->{params}->{emailoverride}) || "" , emailoverride => trim($c->stash->{params}->{emailoverride}) || ""
, hidden => defined $c->stash->{params}->{visible} ? 0 : 1 , hidden => defined $c->stash->{params}->{visible} ? 0 : 1
, keepnr => int(trim($c->stash->{params}->{keepnr})) , keepnr => int(trim($c->stash->{params}->{keepnr}))
@ -232,7 +231,7 @@ sub updateJobset {
my $input = $jobset->jobsetinputs->create({ my $input = $jobset->jobsetinputs->create({
name => $name, name => $name,
type => $type, type => $type,
checkresponsible => $c->stash->{params}->{"input-$baseName-checkresponsible"} emailresponsible => defined $c->stash->{params}->{"input-$baseName-emailresponsible"} ? 1 : 0
}); });
# Set the values for this input. # Set the values for this input.

View file

@ -148,7 +148,7 @@ sub fetchInputSystemBuild {
} }
sub fetchInput { sub fetchInput {
my ($plugins, $db, $project, $jobset, $name, $type, $value, $checkresponsbile) = @_; my ($plugins, $db, $project, $jobset, $name, $type, $value, $emailresponsible) = @_;
my @inputs; my @inputs;
if ($type eq "build") { if ($type eq "build") {
@ -179,7 +179,7 @@ sub fetchInput {
foreach my $input (@inputs) { foreach my $input (@inputs) {
$input->{type} = $type; $input->{type} = $type;
$input->{checkresponsible} = $checkresponsible; $input->{emailresponsible} = $emailresponsible;
} }
return @inputs; return @inputs;
@ -545,7 +545,7 @@ sub checkBuild {
, uri => $input->{uri} , uri => $input->{uri}
, revision => $input->{revision} , revision => $input->{revision}
, value => $input->{value} , value => $input->{value}
, checkresponsible => $input->{checkresponsible} , emailresponsible => $input->{emailresponsible}
, dependency => $input->{id} , dependency => $input->{id}
, path => $input->{storePath} || "" # !!! temporary hack , path => $input->{storePath} || "" # !!! temporary hack
, sha256hash => $input->{sha256hash} , sha256hash => $input->{sha256hash}

View file

@ -259,10 +259,11 @@ sub getResponsibleAuthors {
my $nrCommits = 0; my $nrCommits = 0;
my %authors; my %authors;
my @emailable_authors;
if ($prevBuild) { if ($prevBuild) {
foreach my $curInput ($build->buildinputs_builds) { foreach my $curInput ($build->buildinputs_builds) {
next unless (($curInput->type eq "git" || $curInput->type eq "hg") && $curInput->checkresponsible); next unless ($curInput->type eq "git" || $curInput->type eq "hg");
my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name }); my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name });
next unless defined $prevInput; next unless defined $prevInput;
@ -278,12 +279,13 @@ sub getResponsibleAuthors {
foreach my $commit (@commits) { foreach my $commit (@commits) {
#print STDERR "$commit->{revision} by $commit->{author}\n"; #print STDERR "$commit->{revision} by $commit->{author}\n";
$authors{$commit->{author}} = $commit->{email}; $authors{$commit->{author}} = $commit->{email};
push @emailable_authors, $commit->{email} if $curInput->emailresponsible;
$nrCommits++; $nrCommits++;
} }
} }
} }
return (\%authors, $nrCommits); return (\%authors, $nrCommits, \@emailable_authors);
} }

View file

@ -79,14 +79,12 @@ sub buildFinished {
} }
} }
my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); my ($authors, $nrCommits, $emailable_authors) = getResponsibleAuthors($build, $self->{plugins});
my $authorList; my $authorList;
if (scalar keys %{authors} > 0) { if (scalar keys %{authors} > 0) {
my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors}); my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors});
$authorList = join(" or ", scalar @x > 1 ? join(", ", @[0..scalar @x - 2]): (), $x[-1]); $authorList = join(" or ", scalar @x > 1 ? join(", ", @[0..scalar @x - 2]): (), $x[-1]);
if ($build->jobset->emailresponsible) { $addresses{$_} = { builds => [ $build ] } foreach (@{$emailable_authors});
$addresses{$authors->{$_}} = { builds => [ $build ] } foreach (keys %{$authors});
}
} }
# Send an email to each interested address. # Send an email to each interested address.

View file

@ -72,7 +72,7 @@ __PACKAGE__->table("BuildInputs");
data_type: 'text' data_type: 'text'
is_nullable: 1 is_nullable: 1
=head2 checkresponsible =head2 emailresponsible
data_type: 'integer' data_type: 'integer'
default_value: 0 default_value: 0
@ -111,7 +111,7 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
"value", "value",
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
"checkresponsible", "emailresponsible",
{ data_type => "integer", default_value => 0, is_nullable => 0 }, { data_type => "integer", default_value => 0, is_nullable => 0 },
"dependency", "dependency",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
@ -176,7 +176,7 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:08:15
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ks8PxHXTwtG+Zco0CAzECg # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OaJPzRM+8XGsu3eIkqeYEw
1; 1;

View file

@ -57,7 +57,7 @@ __PACKAGE__->table("JobsetInputs");
data_type: 'text' data_type: 'text'
is_nullable: 0 is_nullable: 0
=head2 checkresponsible =head2 emailresponsible
data_type: 'integer' data_type: 'integer'
default_value: 0 default_value: 0
@ -74,7 +74,7 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 0 }, { data_type => "text", is_nullable => 0 },
"type", "type",
{ data_type => "text", is_nullable => 0 }, { data_type => "text", is_nullable => 0 },
"checkresponsible", "emailresponsible",
{ data_type => "integer", default_value => 0, is_nullable => 0 }, { data_type => "integer", default_value => 0, is_nullable => 0 },
); );
@ -150,7 +150,7 @@ __PACKAGE__->has_many(
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:06:15
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OvSrNdXWqco666sy+rvsKw # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+mZZqLjQNwblb/EWW1alLQ
1; 1;

View file

@ -95,12 +95,6 @@ __PACKAGE__->table("Jobsets");
default_value: 1 default_value: 1
is_nullable: 0 is_nullable: 0
=head2 emailresponsible
data_type: 'integer'
default_value: 0
is_nullable: 0
=head2 hidden =head2 hidden
data_type: 'integer' data_type: 'integer'
@ -160,8 +154,6 @@ __PACKAGE__->add_columns(
{ data_type => "integer", default_value => 1, is_nullable => 0 }, { data_type => "integer", default_value => 1, is_nullable => 0 },
"enableemail", "enableemail",
{ data_type => "integer", default_value => 1, is_nullable => 0 }, { data_type => "integer", default_value => 1, is_nullable => 0 },
"emailresponsible",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
"hidden", "hidden",
{ data_type => "integer", default_value => 0, is_nullable => 0 }, { data_type => "integer", default_value => 0, is_nullable => 0 },
"emailoverride", "emailoverride",
@ -295,7 +287,7 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:06:15
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hJ41oHEb9PjzluvL7f/ypw # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BjT60mlrN7bnljqCMHbPEw
1; 1;

View file

@ -26,7 +26,7 @@
[% IF edit %]<button type="button" class="add-inputalt btn btn-success" onclick='return false'><i class="icon-plus icon-white"></i></button>[% END %] [% IF edit %]<button type="button" class="add-inputalt btn btn-success" onclick='return false'><i class="icon-plus icon-white"></i></button>[% END %]
</td> </td>
<td> <td>
<input type="checkbox" id="[% baseName %]-checkresponsible" name="[% baseName %]-checkresponsible" [% if input.checkresponsible; 'checked="checked"'; END %]/> <input type="checkbox" id="[% baseName %]-emailresponsible" name="[% baseName %]-emailresponsible" [% IF input.emailresponsible; 'checked="checked"'; END %]/>
</td> </td>
</tr> </tr>
[% END %] [% END %]
@ -34,7 +34,7 @@
[% BLOCK renderJobsetInputs %] [% BLOCK renderJobsetInputs %]
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead> <thead>
<tr><th>Input name</th><th>Type</th><th>Values</th><th>Check for responsible commits?</tr> <tr><th>Input name</th><th>Type</th><th>Values</th><th>Notify committers</th></tr>
</thead> </thead>
<tbody class="inputs"> <tbody class="inputs">
[% FOREACH input IN jobset.jobsetinputs %] [% FOREACH input IN jobset.jobsetinputs %]
@ -118,14 +118,6 @@
</div> </div>
</div> </div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="emailresponsible" [% IF jobset.emailresponsible; 'checked="checked"'; END %]/>Notify responsible committers when build status changes
</label>
</div>
</div>
<div class="control-group"> <div class="control-group">
<label class="control-label">Email override</label> <label class="control-label">Email override</label>
<div class="controls"> <div class="controls">
@ -167,7 +159,7 @@
var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show(); var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
$("#input-template-name", x).attr("name", newid + "-name"); $("#input-template-name", x).attr("name", newid + "-name");
$("#input-template-type", x).attr("name", newid + "-type"); $("#input-template-type", x).attr("name", newid + "-type");
$("#input-template-checkresponsible", x).attr("name", newid + "-checkresponsible"); $("#input-template-emailresponsible", x).attr("name", newid + "-emailresponsible");
$("#input-template", x).attr("id", newid); $("#input-template", x).attr("id", newid);
return false; return false;
}); });

View file

@ -34,7 +34,7 @@ sub fetchInputs {
foreach my $input ($jobset->jobsetinputs->all) { foreach my $input ($jobset->jobsetinputs->all) {
foreach my $alt ($input->jobsetinputalts->all) { foreach my $alt ($input->jobsetinputalts->all) {
push @{$$inputInfo{$input->name}}, $_ push @{$$inputInfo{$input->name}}, $_
foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value, $input->checkresponsible); foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value, $input->emailresponsible);
} }
} }
} }

View file

@ -57,7 +57,6 @@ create table Jobsets (
triggerTime integer, -- set if we were triggered by a push event triggerTime integer, -- set if we were triggered by a push event
enabled integer not null default 1, enabled integer not null default 1,
enableEmail integer not null default 1, enableEmail integer not null default 1,
emailResponsible integer not null default 0, -- whether to email committers responsible for a build change
hidden integer not null default 0, hidden integer not null default 0,
emailOverride text not null, emailOverride text not null,
keepnr integer not null default 3, keepnr integer not null default 3,
@ -78,7 +77,7 @@ create table JobsetInputs (
jobset text not null, jobset text not null,
name text not null, name text not null,
type text not null, -- "svn", "path", "uri", "string", "boolean", "nix" type text not null, -- "svn", "path", "uri", "string", "boolean", "nix"
checkResponsible integer not null default 0, -- whether this input should be checked for responsbile commits emailResponsible integer not null default 0, -- whether to email committers to this input who change a build
primary key (project, jobset, name), primary key (project, jobset, name),
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
); );
@ -259,7 +258,7 @@ create table BuildInputs (
uri text, uri text,
revision text, revision text,
value text, value text,
checkResponsible integer not null default 0, emailResponsible integer not null default 0,
dependency integer, -- build ID of the input, for type == 'build' dependency integer, -- build ID of the input, for type == 'build'
path text, path text,

View file

@ -1,3 +1,2 @@
alter table Jobsets add column emailResponsible integer not null default 0; alter table JobsetInputs add column emailResponsible integer not null default 0;
alter table JobsetInputs add column checkResponsible integer not null default 0; alter table BuildInputs add column emailResponsible integer not null default 0;
alter table BuildInputs add column checkResponsible integer not null default 0;