* Support linking to the latest job in a view for a specific platform, e.g.

http://.../view/nixos/tested/latest/iso-minimal-i686-linux.
This commit is contained in:
Eelco Dolstra 2010-03-07 11:24:06 +00:00
parent c9ac5ee215
commit b8a78b2c3f
3 changed files with 16 additions and 10 deletions

View file

@ -192,16 +192,21 @@ sub result : Chained('view') PathPart('') {
[$c->stash->{project}->name, $release->name]));
}
# Provide a redirect to the specified job of this view result.
# !!! This isn't uniquely defined if there are multiple jobs with
# the same name (e.g. builds for different platforms). However,
# this mechanism is primarily to allow linking to resources of
# which there is only one build, such as the manual of the latest
# view result.
# Provide a redirect to the specified job of this view result
# through `http://.../view/$project/$viewName/$viewResult/$jobName'.
# Optionally, you can append `-$system' to the $jobName to get a
# build for a specific platform.
elsif (scalar @args != 0) {
my $jobName = shift @args;
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$result->{jobs}};
notFound($c, "View doesn't have a job named `$jobName'")
my $system;
if ($jobName =~ /^($jobNameRE)-($systemRE)$/) {
$jobName = $1;
$system = $2;
}
(my $build, my @others) =
grep { $_->{job}->job eq $jobName && (!defined $system || ($_->{build} && $_->{build}->system eq $system)) }
@{$result->{jobs}};
notFound($c, "View doesn't have a job named $jobName" . ($system ? " for $system" : "") . ".")
unless defined $build;
error($c, "Job `$jobName' isn't unique.") if @others;
return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'),

View file

@ -11,7 +11,7 @@ our @EXPORT = qw(
error notFound
requireLogin requireProjectOwner requireAdmin requirePost
trim
$pathCompRE $relPathRE $relNameRE $jobNameRE
$pathCompRE $relPathRE $relNameRE $jobNameRE $systemRE
);
@ -174,6 +174,7 @@ Readonly::Scalar our $relPathRE => "(?:$pathCompRE(?:/$pathCompRE)*)";
Readonly::Scalar our $relNameRE => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)";
Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)";
Readonly::Scalar our $jobNameRE => "(?:$attrNameRE(?:\\.$attrNameRE)*)";
Readonly::Scalar our $systemRE => "(?:[a-z0-9_]+-[a-z0-9_]+)";
1;

View file

@ -27,7 +27,7 @@
[% IF j.build.resultInfo.buildstatus == 0 %]
[% IF j.build.buildproducts %]
[% INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' j.job.job] %]
[% INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' "${j.job.job}-${j.build.system}"] %]
[% ELSE %]
<p><em>Succeeded.</em></p>
[% END %]