* 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:
		| @@ -192,16 +192,21 @@ sub result : Chained('view') PathPart('') { | |||||||
|             [$c->stash->{project}->name, $release->name])); |             [$c->stash->{project}->name, $release->name])); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     # Provide a redirect to the specified job of this view result. |     # Provide a redirect to the specified job of this view result | ||||||
|     # !!!  This isn't uniquely defined if there are multiple jobs with |     # through `http://.../view/$project/$viewName/$viewResult/$jobName'.  | ||||||
|     # the same name (e.g. builds for different platforms).  However, |     # Optionally, you can append `-$system' to the $jobName to get a | ||||||
|     # this mechanism is primarily to allow linking to resources of |     # build for a specific platform. | ||||||
|     # which there is only one build, such as the manual of the latest |  | ||||||
|     # view result. |  | ||||||
|     elsif (scalar @args != 0) { |     elsif (scalar @args != 0) { | ||||||
|         my $jobName = shift @args; |         my $jobName = shift @args; | ||||||
|         (my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$result->{jobs}}; |         my $system; | ||||||
|         notFound($c, "View doesn't have a job named `$jobName'") |         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; |             unless defined $build; | ||||||
|         error($c, "Job `$jobName' isn't unique.") if @others; |         error($c, "Job `$jobName' isn't unique.") if @others; | ||||||
|         return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'), |         return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'), | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ our @EXPORT = qw( | |||||||
|     error notFound |     error notFound | ||||||
|     requireLogin requireProjectOwner requireAdmin requirePost |     requireLogin requireProjectOwner requireAdmin requirePost | ||||||
|     trim |     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 $relNameRE  => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)"; | ||||||
| Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)"; | Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)"; | ||||||
| Readonly::Scalar our $jobNameRE  => "(?:$attrNameRE(?:\\.$attrNameRE)*)"; | Readonly::Scalar our $jobNameRE  => "(?:$attrNameRE(?:\\.$attrNameRE)*)"; | ||||||
|  | Readonly::Scalar our $systemRE   => "(?:[a-z0-9_]+-[a-z0-9_]+)"; | ||||||
|  |  | ||||||
|  |  | ||||||
| 1; | 1; | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ | |||||||
|     [% IF j.build.resultInfo.buildstatus == 0 %] |     [% IF j.build.resultInfo.buildstatus == 0 %] | ||||||
|  |  | ||||||
|       [% IF j.build.buildproducts %] |       [% 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 %] |       [% ELSE %] | ||||||
|         <p><em>Succeeded.</em></p> |         <p><em>Succeeded.</em></p> | ||||||
|       [% END %] |       [% END %] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user