Allow creating a release from an evaluation

This commit is contained in:
Eelco Dolstra 2012-07-18 23:46:41 +02:00
parent 2ab4c7d597
commit 67528698e6
2 changed files with 42 additions and 0 deletions

View file

@ -99,6 +99,42 @@ sub view : Chained('eval') PathPart('') Args(0) {
}
sub release : Chained('eval') PathPart('release') Args(0) {
my ($self, $c) = @_;
my $eval = $c->stash->{eval};
requireProjectOwner($c, $c->stash->{project});
my @builds = $eval->builds;
my $releaseName;
$releaseName ||= $_->releasename foreach @builds;
error($c, "No build in this evaluation has a release name.")
unless defined $releaseName;
my $release;
txn_do($c->model('DB')->schema, sub {
$release = $c->stash->{project}->releases->create(
{ name => $releaseName
, timestamp => time
});
foreach my $build (@builds) {
$release->releasemembers->create(
{ build => $build->id
, description => $build->description
}) if $build->buildstatus == 0;
}
});
$c->res->redirect($c->uri_for($c->controller('Release')->action_for('view'),
[$c->stash->{project}->name, $release->name]));
}
# Hydra::Base::Controller::NixChannel needs this.
sub nix : Chained('eval') PathPart('channel') CaptureArgs(0) {
my ($self, $c) = @_;

View file

@ -69,4 +69,10 @@ c.uri_for(c.controller('JobsetEval').action_for('view'),
[% INCLUDE renderBuildListFooter %]
[% IF c.user_exists %]
<p>
<a class="btn" href="[% c.uri_for(c.controller('JobsetEval').action_for('release'), [eval.id]) %]">Release</a>
</p>
[% END %]
[% END %]