From bf2a5a26291da26ecd9d89bf35f6eff0af7f030f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 Apr 2009 09:37:05 +0000 Subject: [PATCH] * Allow omitting the product number if there is only one product in a build. This allows URLs like http://server/job/patchelf/trunk/deb_debian40i386/latest/download or http://server/release/patchelf/unstable/latest/deb_debian40i386/download --- src/lib/Hydra/Controller/Build.pm | 4 +++- src/root/product-list.tt | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index d324ed2c..083d5f39 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -102,8 +102,10 @@ sub defaultUriForProduct { sub download : Chained('build') PathPart { my ($self, $c, $productnr, @path) = @_; + $productnr = 1 if !defined $productnr; + my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr}); - notFound($c, "Build doesn't have a product $productnr.") if !defined $product; + notFound($c, "Build doesn't have a product #$productnr.") if !defined $product; notFound($c, "Product " . $product->path . " has disappeared.") unless -e $product->path; diff --git a/src/root/product-list.tt b/src/root/product-list.tt index 7311cbfa..01c55acb 100644 --- a/src/root/product-list.tt +++ b/src/root/product-list.tt @@ -2,6 +2,10 @@ [% BLOCK renderProductList -%] + [% # Work around a strange bug: build.buildproducts.size returns 3 when the actual size is 1. + nrProducts = 0; FOREACH product IN build.buildproducts; nrProducts = nrProducts + 1; END + %] +