* hydra: buildpage, show changes since last build/successful build

This commit is contained in:
Rob Vermaas 2010-02-22 13:21:34 +00:00
parent fb8ab7a574
commit 529a6cf6eb
4 changed files with 88 additions and 3 deletions

View file

@ -15,6 +15,8 @@ sub build : Chained('/') PathPart CaptureArgs(1) {
$c->stash->{id} = $id;
$c->stash->{build} = getBuild($c, $id);
$c->stash->{prevBuild} = getPreviousBuild($c, $c->stash->{build});
$c->stash->{prevSuccessfulBuild} = getPreviousSuccessfulBuild($c, $c->stash->{build});
notFound($c, "Build with ID $id doesn't exist.")
if !defined $c->stash->{build};
@ -22,7 +24,6 @@ sub build : Chained('/') PathPart CaptureArgs(1) {
$c->stash->{project} = $c->stash->{build}->project;
}
sub view_build : Chained('build') PathPart('') Args(0) {
my ($self, $c) = @_;

View file

@ -7,7 +7,7 @@ use Hydra::Helper::Nix;
our @ISA = qw(Exporter);
our @EXPORT = qw(
getBuild getBuildStats joinWithResultInfo getChannelData
getBuild getPreviousBuild getPreviousSuccessfulBuild getBuildStats joinWithResultInfo getChannelData
error notFound
requireLogin requireProjectOwner requireAdmin requirePost
trim
@ -21,6 +21,34 @@ sub getBuild {
return $build;
}
sub getPreviousBuild {
my ($c, $build) = @_;
(my $prevBuild) = $c->model('DB::Builds')->search(
{ finished => 1
, system => $build->system
, project => $build->project->name
, jobset => $build->jobset->name
, job => $build->job->name
, 'me.id' => { '<' => $build->id }
}, {rows => 1, order_by => "id DESC"});
return $prevBuild;
}
sub getPreviousSuccessfulBuild {
my ($c, $build) = @_;
(my $prevBuild) = joinWithResultInfo($c, $c->model('DB::Builds'))->search(
{ finished => 1
, system => $build->system
, project => $build->project->name
, jobset => $build->jobset->name
, job => $build->job->name
, buildstatus => 0
, 'me.id' => { '<' => $build->id }
}, {rows => 1, order_by => "id DESC"});
return $prevBuild;
}
sub getBuildStats {
my ($c, $builds) = @_;

View file

@ -175,7 +175,7 @@
[% END %]
[% IF !build.finished %]
[% IF !build.finished %]
[% INCLUDE renderBuildSteps type="Running" %]
[% END %]
@ -383,6 +383,17 @@
[% END -%]
</tbody>
</table>
[% IF prevBuild %]
<h2>Changes since previous build : [% INCLUDE renderFullBuildLink build=prevBuild %]</h2>
[% INCLUDE renderInputDiff build2=build , build1=prevBuild %]
[% END %]
[% IF prevBuild && prevSuccessfulBuild.id != prevBuild.id %]
<h2>Changes since previous successful build : [% INCLUDE renderFullBuildLink build=prevSuccessfulBuild %]</h2>
[% INCLUDE renderInputDiff build2=build , build1=prevSuccessfulBuild %]
[% END %]
</div>

View file

@ -265,3 +265,48 @@
[% END %]
[% END -%]
[% BLOCK renderInputValue %]
[% IF input.type == "build" || input.type == "sysbuild" %]
[% INCLUDE renderFullBuildLink build=input.dependency %]</a>
[% ELSIF input.type == "string" || input.type == "boolean" %]
<tt>"[% input.value %]"</tt>
[% ELSE %]
<tt>[% input.uri %][% IF input.revision %] (r. [% input.revision %])[% END %]</tt>
[% END %]
[% END %]
[% BLOCK renderInputDiff; %]
<table class="tablesorter">
<thead>
<tr><th>Name</th><th>Change</th></tr>
</thead>
<tbody>
[% FOREACH bi1 IN build1.inputs %]
[% deletedInput = 1 %]
[% FOREACH bi2 IN build2.inputs %]
[% IF bi1.name == bi2.name %]
<tr>
[% IF bi1.type == bi2.type %]
[% IF bi1.value != bi2.value || bi1.uri != bi2.uri || bi1.revision != bi2.revision || bi1.path != bi2.path || bi1.dependency != bi2.dependency %]
<td>[% bi1.name %]</td>
<td>
[% INCLUDE renderInputValue input=bi1 %] to [% INCLUDE renderInputValue input=bi2 %]
</td>
[% END %]
[% ELSE %]
<td>[% bi1.name %]</td>
<td>Changed input type from '[% type = bi1.type; inputTypes.$type %]' to '[% type = bi2.type; inputTypes.$type %]'</td>
[% END %]
</tr>
[% deletedInput = 0 %]
[% END %]
[% END %]
[% IF deletedInput == 1 %]
<tr><td>[% bi1.name %]</td><td>Input not present in this build.</td></tr>
[% END %]
[% END %]
</tbody>
</table>
[% END %]