* Allow a view result to be saved as a release.
This commit is contained in:
parent
9aa70716ad
commit
3e5e49debd
|
@ -159,7 +159,38 @@ sub result : Chained('view') PathPart('') {
|
||||||
, '+as' => ["releasename", "buildstatus"] })
|
, '+as' => ["releasename", "buildstatus"] })
|
||||||
or error($c, "Build $id doesn't exist.");
|
or error($c, "Build $id doesn't exist.");
|
||||||
|
|
||||||
$c->stash->{result} = getViewResult($primaryBuild, $c->stash->{jobs});
|
my $result = getViewResult($primaryBuild, $c->stash->{jobs});
|
||||||
|
$c->stash->{result} = $result;
|
||||||
|
|
||||||
|
if (scalar @args == 1 && $args[0] eq "release") {
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
error($c, "The primary build of this view result did not provide a release name.")
|
||||||
|
unless $result->{releasename};
|
||||||
|
|
||||||
|
error($c, "A release named `" . $result->{releasename} . "' already exists.")
|
||||||
|
if $c->stash->{project}->releases->find({name => $result->{releasename}});
|
||||||
|
|
||||||
|
my $release;
|
||||||
|
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
|
||||||
|
$release = $c->stash->{project}->releases->create(
|
||||||
|
{ name => $result->{releasename}
|
||||||
|
, timestamp => time
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach my $job (@{$result->{jobs}}) {
|
||||||
|
$release->releasemembers->create(
|
||||||
|
{ build => $job->{build}->id
|
||||||
|
, description => $job->{job}->description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for($c->controller('Release')->action_for('view'),
|
||||||
|
[$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
|
# !!! This isn't uniquely defined if there are multiple jobs with
|
||||||
|
@ -167,9 +198,9 @@ sub result : Chained('view') PathPart('') {
|
||||||
# this mechanism is primarily to allow linking to resources of
|
# this mechanism is primarily to allow linking to resources of
|
||||||
# which there is only one build, such as the manual of the latest
|
# which there is only one build, such as the manual of the latest
|
||||||
# view result.
|
# view result.
|
||||||
if (scalar @args != 0) {
|
elsif (scalar @args != 0) {
|
||||||
my $jobName = shift @args;
|
my $jobName = shift @args;
|
||||||
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{result}->{jobs}};
|
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$result->{jobs}};
|
||||||
notFound($c, "View doesn't have a job named `$jobName'")
|
notFound($c, "View doesn't have a job named `$jobName'")
|
||||||
unless defined $build;
|
unless defined $build;
|
||||||
error($c, "Job `$jobName' isn't unique.") if @others;
|
error($c, "Job `$jobName' isn't unique.") if @others;
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
<th>URL:</th>
|
<th>URL:</th>
|
||||||
<td><a href="[% uri %]"><tt>[% uri %]</tt></a></td>
|
<td><a href="[% uri %]"><tt>[% uri %]</tt></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
[% IF latestRoot %]
|
||||||
<tr>
|
<tr>
|
||||||
<th>Links to latest:</th>
|
<th>Links to latest:</th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
[% END %]
|
[% END %]
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
[% END %]
|
||||||
<tr><th>File size:</th><td>[% product.filesize %] bytes ([% mibs(product.filesize / (1024 * 1024)) %] MiB)</td></tr>
|
<tr><th>File size:</th><td>[% product.filesize %] bytes ([% mibs(product.filesize / (1024 * 1024)) %] MiB)</td></tr>
|
||||||
<tr><th>SHA-1 hash:</th><td><tt>[% product.sha1hash %]</tt></td></tr>
|
<tr><th>SHA-1 hash:</th><td><tt>[% product.sha1hash %]</tt></td></tr>
|
||||||
<tr><th>SHA-256 hash:</th><td><tt>[% product.sha256hash %]</tt></td></tr>
|
<tr><th>SHA-256 hash:</th><td><tt>[% product.sha256hash %]</tt></td></tr>
|
||||||
|
|
|
@ -23,7 +23,7 @@ release.timestamp %].</em></p>
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
[% INCLUDE renderProductList build=m.build latestRoot=['/view!!!' project.name view.name 'latest' j.job.job] %]
|
[% INCLUDE renderProductList build=m.build %]
|
||||||
|
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
|
|
@ -42,4 +42,10 @@
|
||||||
|
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
[% IF c.user_exists %]
|
||||||
|
<p>
|
||||||
|
[<a href="[% c.uri_for('/view' project.name view.name result.id 'release') %]">Release</a>]
|
||||||
|
</p>
|
||||||
|
[% END %]
|
||||||
|
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in a new issue