Archived
1
0

Fix index in hook

This commit is contained in:
Mercier Pierre-Olivier 2013-09-24 01:40:10 +02:00
parent 89f9c5c6d3
commit d346848b90

View File

@ -216,28 +216,28 @@ sub tag_grades
my $creation = shift; my $creation = shift;
# From here, we have: # From here, we have:
# 1: "defense" # 0: "defense"
# 2: $version # 1: $version
# 3: $id # 2: $id
# 4: $year # 3: $year
my $version = $_[2] // 1; my $version = $_[1] // 1;
my $project_id = repository_name(); my $project_id = repository_name();
if ($_[3]) { if ($_[2]) {
$project_id .= "-" . $_[3]; $project_id .= "-" . $_[2];
} }
$project_id = lc $project_id; $project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g; $project_id =~ s/[^a-z0-9-_]/_/g;
my $year; my $year;
if ($_[4]) { if ($_[3]) {
# Check on year # Check on year
if ($_[4] !~ /^\d+$/) { if ($_[3] !~ /^\d+$/) {
log ERROR, "grades,*,*,* second argument is the year. Tag format: grades,version,id,year"; log ERROR, "grades,*,*,* second argument is the year. Tag format: grades,version,id,year";
} }
$year = $_[4]; $year = $_[3];
} }
else { else {
$year = LDAP::get_year; $year = LDAP::get_year;
@ -246,7 +246,7 @@ sub tag_grades
# Determine full tag # Determine full tag
my $long_tag; my $long_tag;
{ {
my $proj_id = $_[3] // ""; my $proj_id = $_[2] // "";
$long_tag = "grades,$version,$proj_id,$year"; $long_tag = "grades,$version,$proj_id,$year";
} }
@ -302,31 +302,31 @@ sub tag_project
my $creation = shift; my $creation = shift;
# From here, we have: # From here, we have:
# 1: "project" # 0: "project"
# 2: $id # 1: $id
# 3: $year # 2: $year
my $project_id = repository_name(); my $project_id = repository_name();
if ($_[2]) { if ($_[1]) {
# Check on ID/flavour_id # Check on ID/flavour_id
if ($_[2] =~ /^\d+$/) { if ($_[1] =~ /^\d+$/) {
log ERROR, "project:* tag can't take version. Tag format: project:id:year"; log ERROR, "project:* tag can't take version. Tag format: project:id:year";
} }
$project_id .= "-" . $_[2]; $project_id .= "-" . $_[1];
} }
$project_id = lc $project_id; $project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g; $project_id =~ s/[^a-z0-9-_]/_/g;
my $year; my $year;
if ($_[3]) { if ($_[2]) {
# Check on year # Check on year
if ($_[3] !~ /^\d+$/) { if ($_[2] !~ /^\d+$/) {
log ERROR, "project:*:* second argument is the year. Tag format: project:id:year"; log ERROR, "project:*:* second argument is the year. Tag format: project:id:year";
} }
$year = $_[3]; $year = $_[2];
} }
else { else {
$year = LDAP::get_year; $year = LDAP::get_year;
@ -334,9 +334,9 @@ sub tag_project
# Determine full tag # Determine full tag
my $long_tag; my $long_tag;
if (!$_[3]) if (!$_[2])
{ {
my $proj_id = $_[2] // ""; my $proj_id = $_[1] // "";
$long_tag = "project,$proj_id,$year"; $long_tag = "project,$proj_id,$year";
} }
@ -393,7 +393,8 @@ sub tag_project
} }
my $token; my $token;
do { do
{
$token = sha1_base64(rand); $token = sha1_base64(rand);
$token =~ s/[^a-zA-Z0-9]//g; $token =~ s/[^a-zA-Z0-9]//g;
} while (length $token < 12); } while (length $token < 12);
@ -466,40 +467,41 @@ sub tag_ref
my $creation = shift; my $creation = shift;
# From here, we have: # From here, we have:
# 1: "ref" # 0: "ref"
# 2: $id # 1: $id
# 3: rendu-X # 2: rendu-X
# 4: $year # 3: $year
my $project_id = repository_name(); my $project_id = repository_name();
if ($_[2]) { if ($_[1]) {
# Check on ID/flavour_id # Check on ID/flavour_id
if ($_[2] =~ /^\d+$/) { if ($_[1] =~ /^\d+$/) {
log ERROR, "ref,* tag can't take version. Tag format: ref,id,rendu,year"; log ERROR, "ref,* tag can't take version. Tag format: ref,id,rendu,year";
} }
$project_id .= "-" . $_[2]; $project_id .= "-" . $_[1];
} }
$project_id = lc $project_id; $project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g; $project_id =~ s/[^a-z0-9-_]/_/g;
my $rendu; my $rendu;
if ($_[3]) { if ($_[2]) {
$rendu = $_[3]; $rendu = $_[2];
} }
else { else {
$rendu = "*"; $rendu = "*";
} }
my $year; my $year;
if ($_[4]) { if ($_[3])
{
# Check on year # Check on year
if ($_[4] !~ /^\d+$/) { if ($_[3] !~ /^\d+$/) {
log ERROR, "ref,*,*,* third argument is the year. Tag format: ref,id,rendu,year"; log ERROR, "ref,*,*,* third argument is the year. Tag format: ref,id,rendu,year";
} }
$year = $_[4]; $year = $_[3];
} }
else { else {
$year = LDAP::get_year; $year = LDAP::get_year;
@ -508,7 +510,7 @@ sub tag_ref
# Determine full tag # Determine full tag
my $long_tag; my $long_tag;
{ {
my $proj_id = $_[2] // ""; my $proj_id = $_[1] // "";
$long_tag = "ref,$proj_id,$rendu,$year"; $long_tag = "ref,$proj_id,$rendu,$year";
} }