From 529a6cf6ebcf76be130cc3d403d412fe5faa1119 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Mon, 22 Feb 2010 13:21:34 +0000 Subject: [PATCH] * hydra: buildpage, show changes since last build/successful build --- src/lib/Hydra/Controller/Build.pm | 3 +- src/lib/Hydra/Helper/CatalystUtils.pm | 30 +++++++++++++++++- src/root/build.tt | 13 +++++++- src/root/common.tt | 45 +++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 0e0471ee..e94f1559 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -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) = @_; diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 7de3a8ee..f838812c 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -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) = @_; diff --git a/src/root/build.tt b/src/root/build.tt index 1473ddef..a497362e 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -175,7 +175,7 @@ [% END %] - [% IF !build.finished %] + [% IF !build.finished %] [% INCLUDE renderBuildSteps type="Running" %] [% END %] @@ -383,6 +383,17 @@ [% END -%] + + [% IF prevBuild %] +

Changes since previous build : [% INCLUDE renderFullBuildLink build=prevBuild %]

+ [% INCLUDE renderInputDiff build2=build , build1=prevBuild %] + [% END %] + + [% IF prevBuild && prevSuccessfulBuild.id != prevBuild.id %] +

Changes since previous successful build : [% INCLUDE renderFullBuildLink build=prevSuccessfulBuild %]

+ [% INCLUDE renderInputDiff build2=build , build1=prevSuccessfulBuild %] + [% END %] + diff --git a/src/root/common.tt b/src/root/common.tt index a1dc377e..a91ecb96 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -265,3 +265,48 @@ [% END %] [% END -%] +[% BLOCK renderInputValue %] + [% IF input.type == "build" || input.type == "sysbuild" %] + [% INCLUDE renderFullBuildLink build=input.dependency %] + [% ELSIF input.type == "string" || input.type == "boolean" %] + "[% input.value %]" + [% ELSE %] + [% input.uri %][% IF input.revision %] (r. [% input.revision %])[% END %] + [% END %] +[% END %] + +[% BLOCK renderInputDiff; %] + + + + + + + [% FOREACH bi1 IN build1.inputs %] + [% deletedInput = 1 %] + [% FOREACH bi2 IN build2.inputs %] + [% IF bi1.name == bi2.name %] + + [% 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 %] + + + [% END %] + [% ELSE %] + + + [% END %] + + [% deletedInput = 0 %] + [% END %] + [% END %] + [% IF deletedInput == 1 %] + + [% END %] + [% END %] + +
NameChange
[% bi1.name %] + [% INCLUDE renderInputValue input=bi1 %] to [% INCLUDE renderInputValue input=bi2 %] + [% bi1.name %]Changed input type from '[% type = bi1.type; inputTypes.$type %]' to '[% type = bi2.type; inputTypes.$type %]'
[% bi1.name %]Input not present in this build.
+[% END %] +