forked from lix-project/hydra
Allow creating a release from an evaluation
This commit is contained in:
parent
2ab4c7d597
commit
67528698e6
|
@ -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.
|
# Hydra::Base::Controller::NixChannel needs this.
|
||||||
sub nix : Chained('eval') PathPart('channel') CaptureArgs(0) {
|
sub nix : Chained('eval') PathPart('channel') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
|
@ -69,4 +69,10 @@ c.uri_for(c.controller('JobsetEval').action_for('view'),
|
||||||
|
|
||||||
[% INCLUDE renderBuildListFooter %]
|
[% 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 %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in a new issue