forked from lix-project/hydra
* Provide a redirect to the latest successful release in a release set
(e.g. http://localhost:3000/release/patchelf/unstable/latest).
This commit is contained in:
parent
3a26ab4b21
commit
5e207cdbb2
|
@ -308,6 +308,18 @@ sub updateReleaseSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub getPrimaryBuildsForReleaseSet {
|
||||||
|
my ($project, $primaryJob) = @_;
|
||||||
|
my @primaryBuilds = $project->builds->search(
|
||||||
|
{ attrname => $primaryJob->job, finished => 1 },
|
||||||
|
{ join => 'resultInfo', order_by => "timestamp DESC"
|
||||||
|
, '+select' => ["resultInfo.releasename"], '+as' => ["releasename"]
|
||||||
|
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
||||||
|
});
|
||||||
|
return @primaryBuilds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub releases :Local {
|
sub releases :Local {
|
||||||
my ($self, $c, $projectName, $releaseSetName, $subcommand) = @_;
|
my ($self, $c, $projectName, $releaseSetName, $subcommand) = @_;
|
||||||
|
|
||||||
|
@ -343,16 +355,9 @@ sub releases :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
$c->stash->{template} = 'releases.tt';
|
$c->stash->{template} = 'releases.tt';
|
||||||
my @primaryBuilds = $project->builds->search(
|
|
||||||
{ attrname => $primaryJob->job, finished => 1 },
|
|
||||||
{ join => 'resultInfo', order_by => "timestamp DESC"
|
|
||||||
, '+select' => ["resultInfo.releasename"], '+as' => ["releasename"]
|
|
||||||
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
|
||||||
});
|
|
||||||
|
|
||||||
my @releases = ();
|
my @releases = ();
|
||||||
push @releases, getRelease($c, $_) foreach @primaryBuilds;
|
push @releases, getRelease($c, $_) foreach getPrimaryBuildsForReleaseSet($project, $primaryJob);
|
||||||
|
|
||||||
$c->stash->{releases} = [@releases];
|
$c->stash->{releases} = [@releases];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,6 +402,21 @@ sub release :Local {
|
||||||
|
|
||||||
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseSetName);
|
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseSetName);
|
||||||
|
|
||||||
|
if ($releaseId eq "latest") {
|
||||||
|
# Redirect to the latest successful release.
|
||||||
|
my $latest;
|
||||||
|
foreach my $release (getPrimaryBuildsForReleaseSet($project, $primaryJob)) {
|
||||||
|
if (getRelease($c, $release)->{status} == 0) {
|
||||||
|
$latest = $release;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 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));
|
||||||
|
}
|
||||||
|
|
||||||
# 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,
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
<h1>Release Set <tt>[% releaseSet.project.name %]:[% releaseSet.name %]</tt></h1>
|
<h1>Release Set <tt>[% releaseSet.project.name %]:[% releaseSet.name %]</tt></h1>
|
||||||
|
|
||||||
<p>[<a href="[% c.uri_for('/releases' curProject.name releaseSet.name "edit") %]">Edit</a>]</p>
|
<p>
|
||||||
|
[<a href="[% c.uri_for('/releases' curProject.name releaseSet.name "edit") %]">Edit</a>]
|
||||||
|
[<a href="[% c.uri_for('/release' curProject.name releaseSet.name "latest") %]">Latest</a>]
|
||||||
|
</p>
|
||||||
|
|
||||||
<table class="tablesorter">
|
<table class="tablesorter">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
Loading…
Reference in a new issue