* Support redirecting to some job of a release. For instance, this

redirects to the "tarball" build of the latest release of
  patchelf/unstable:

    http://server/release/patchelf/unstable/latest/tarball

  In conjunction with the other redirects this allows linking to the
  actual download of the build:

    http://server/release/patchelf/unstable/latest/tarball/download-by-type/file/source-dist
This commit is contained in:
Eelco Dolstra 2009-04-08 09:03:45 +00:00
parent 26ff5f1ff0
commit 11d8421def
4 changed files with 24 additions and 8 deletions

View file

@ -197,7 +197,7 @@ sub create_releaseset :Local {
sub release :Local { sub release :Local {
my ($self, $c, $projectName, $releaseSetName, $releaseId) = @_; my ($self, $c, $projectName, $releaseSetName, $releaseId, @args) = @_;
$c->stash->{template} = 'release.tt'; $c->stash->{template} = 'release.tt';
my ($project, $releaseSet, $primaryJob, $jobs) = getReleaseSet($c, $projectName, $releaseSetName); my ($project, $releaseSet, $primaryJob, $jobs) = getReleaseSet($c, $projectName, $releaseSetName);
@ -206,9 +206,9 @@ sub release :Local {
# Redirect to the latest successful release. # Redirect to the latest successful release.
my $latest = getLatestSuccessfulRelease($project, $primaryJob, $jobs); my $latest = getLatestSuccessfulRelease($project, $primaryJob, $jobs);
error($c, "This release set has no successful releases yet.") if !defined $latest; error($c, "This release set has no successful releases yet.") if !defined $latest;
return $c->res->redirect($c->uri_for("/release", $projectName, $releaseSetName, $latest->id)); return $c->res->redirect($c->uri_for("/release", $projectName, $releaseSetName, $latest->id, @args));
} }
# Note: we don't actually check whether $releaseId is a primary # Note: we don't actually check whether $releaseId is a primary
# build, but who cares? # build, but who cares?
my $primaryBuild = $project->builds->find($releaseId, my $primaryBuild = $project->builds->find($releaseId,
@ -218,6 +218,22 @@ sub release :Local {
or error($c, "Release $releaseId doesn't exist."); or error($c, "Release $releaseId doesn't exist.");
$c->stash->{release} = getRelease($primaryBuild, $jobs); $c->stash->{release} = getRelease($primaryBuild, $jobs);
# Provide a redirect to the specified job of this release. !!!
# 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
# release.
if (scalar @args != 0) {
my $jobName = shift @args;
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{release}->{jobs}};
notFound($c, "Release doesn't have a job named `$jobName'")
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'),
[$build->{build}->id], @args));
}
} }

View file

@ -308,7 +308,7 @@
<p class="error">Note: this build is no longer available.</p> <p class="error">Note: this build is no longer available.</p>
[% END %] [% END %]
[% INCLUDE renderProductList %] [% INCLUDE renderProductList latestRoot=['/job' build.project.name build.jobset.name build.job.name 'latest'] %]
[% END %] [% END %]

View file

@ -108,10 +108,10 @@
<tr> <tr>
<th>Links to latest:</th> <th>Links to latest:</th>
<td> <td>
[% uri2 = "${c.uri_for('/job' build.project.name build.jobset.name build.job.name 'latest' 'download-by-type' product.type product.subtype)}" %] [% uri2 = "${c.uri_for(latestRoot.join('/') 'download-by-type' product.type product.subtype)}" %]
<a href="[% uri2 %]"><tt>[% uri2 %]</tt></a> <a href="[% uri2 %]"><tt>[% uri2 %]</tt></a>
<br /> <br />
[% uri2 = "${c.uri_for('/job' build.project.name build.jobset.name build.job.name 'latest' 'download' product.productnr)}" %] [% uri2 = "${c.uri_for(latestRoot.join('/') 'download' product.productnr)}" %]
<a href="[% uri2 %]"><tt>[% uri2 %]</tt></a> <a href="[% uri2 %]"><tt>[% uri2 %]</tt></a>
</td> </td>
</tr> </tr>

View file

@ -17,7 +17,7 @@
[% FOREACH j IN release.jobs %] [% FOREACH j IN release.jobs %]
<h2> <h2>
[% IF j.build %]<a href="[% c.uri_for('/build' job.build.id) %]">[% END %] [% IF j.build %]<a href="[% c.uri_for('/build' j.build.id) %]">[% END %]
[% INCLUDE renderReleaseJobName job=j.job %] [% INCLUDE renderReleaseJobName job=j.job %]
[% IF j.build %]</a>[% END %] [% IF j.build %]</a>[% END %]
</h2> </h2>
@ -26,7 +26,7 @@
[% IF j.build.resultInfo.buildstatus == 0 %] [% IF j.build.resultInfo.buildstatus == 0 %]
[% INCLUDE renderProductList build=j.build %] [% INCLUDE renderProductList build=j.build latestRoot=['/release' project.name releaseSet.name 'latest' j.job.job] %]
[% ELSE %] [% ELSE %]