diff --git a/hooks/subjects.pl b/hooks/subjects.pl index bd3cd6c..30e2cf1 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -89,27 +89,32 @@ sub tag_project { my $creation = shift; + # From here, we have: + # 1: "project" + # 2: $id + # 3: $year + my $project_id = repository_name(); - if ($_[1]) { + if ($_[2]) { # Check on ID/flavour_id - if ($_[1] =~ /^\d+$/) { + if ($_[2] =~ /^\d+$/) { log ERROR, "project:* tag can't take version. Tag format: project:id:year"; } - $project_id .= "-" . $_[1]; + $project_id .= "-" . $_[2]; } $project_id = lc $project_id; $project_id =~ s/[^a-z0-9-_]/_/g; my $year; - if ($_[2]) { + if ($_[3]) { # Check on year - if ($_[2] !~ /^\d+$/) { + if ($_[3] !~ /^\d+$/) { log ERROR, "project:*:* second argument is the year. Tag format: project:id:year"; } - $year = $_[2]; + $year = $_[3]; } else { $year = LDAP::get_year; @@ -142,12 +147,10 @@ sub tag_project if (Process::Client::launch("intradata_get", { action => "update", type => "project", id => $project_id, "year" => $year }, { "butler.xml" => $content })); # Call API - my $err = API::Projects::add($project_id, $year); - log ERROR, $err if ($err); + log ERROR, $_ if(API::Projects::add($project_id, $year)); # FIXME: Remove next line after 2016 piscine: ça ne devrait pas être fait à ce moment là - $err = API::Projects::gen_groups($project_id, $year); - log ERROR, $err if ($err); + log ERROR, $_ if(API::Projects::gen_groups($project_id, $year)); } else {