From 6284fd540d328dbfe4b687410828ee5b948978d3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 18:12:30 +0200 Subject: [PATCH] Disallow multiple jobs with the same name This has been deprecated since a8db32983969b9b1f11a3bedb2bb8cd2d04a9465. Issue #60. --- src/lib/Hydra/Helper/AddBuilds.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index bcee1be9..86e56d57 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -351,8 +351,19 @@ sub evalJobs { SuppressEmpty => '') or die "cannot parse XML output"; + my %jobNames; + my $errors; my @filteredJobs = (); foreach my $job (@{$jobs->{job}}) { + # Ensure that there is only one job with the given + # name. FIXME: this check will become unnecessary after we + # remove support for multiple values per jobset input. + if (defined $jobNames{$job->{jobName}}) { + $errors .= "error: there are multiple jobs named ‘$job->{jobName}’\n\n"; + next; + } + $jobNames{$job->{jobName}} = 1; + my $validJob = 1; foreach my $arg (@{$job->{arg}}) { my $input = $inputInfo->{$arg->{name}}->[$arg->{altnr}]; @@ -362,15 +373,6 @@ sub evalJobs { } $jobs->{job} = \@filteredJobs; - my %jobNames; - my $errors; - foreach my $job (@{$jobs->{job}}) { - $jobNames{$job->{jobName}}++; - if ($jobNames{$job->{jobName}} == 2) { - $errors .= "warning: there are multiple jobs named ‘$job->{jobName}’; support for this will go away soon!\n\n"; - } - } - # Handle utf-8 characters in error messages. No idea why this works. utf8::decode($_->{msg}) foreach @{$jobs->{error}};