Archived
1
0

Fix bad index to create defense

This commit is contained in:
Mercier Pierre-Olivier 2013-09-24 00:24:47 +02:00
parent 59aff8677a
commit dd088dd210

View File

@ -78,36 +78,36 @@ sub tag_defense
my $creation = shift;
# From here, we have:
# 1: "defense"
# 2: $version
# 3: $id
# 4: $path
# 5: $year
# 0: "defense"
# 1: $version
# 2: $id
# 3: $path
# 4: $year
my $version = $_[2] // 1;
my $version = $_[1] // 1;
my $project_id = repository_name();
if ($_[3]) {
$project_id .= "-" . $_[3];
if ($_[2]) {
$project_id .= "-" . $_[2];
}
$project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g;
my $path;
if ($_[4])
if ($_[3])
{
if ($_[4] =~ /(?:defenses\/)?([a-zA-Z0-9\/]+)(?:.xml)/) {
if ($_[3] =~ /(?:defenses\/)?([a-zA-Z0-9\/]+)(?:.xml)/) {
$path = "defenses/".$1.".xml";
} else {
$path = $_[4];
$path = $_[3];
}
}
else {
# Looking for an uniq defense file in defenses/
$path = qx(git ls-tree -r --name-only HEAD defenses/ | egrep '\.xml\$');
$path = qx(git ls-tree -r --name-only $ARGV[2] defenses/ | egrep '\.xml\$');
my $nb_defenses = $path =~ tr/\n//;
if ($nb_defenses > 1) {
log ERROR, "Veuillez préciser le chemin de la soutenance à utiliser";
log ERROR, "Veuillez préciser le chemin de la soutenance à utiliser avec un tag : defense,$_[1],$_[2],file_to_use";
exit 1;
}
elsif ($nb_defenses == 0) {
@ -125,14 +125,14 @@ sub tag_defense
}
my $year;
if ($_[5])
if ($_[4])
{
# Check on year
if ($_[5] !~ /^\d+$/) {
if ($_[4] !~ /^\d+$/) {
log ERROR, "project:*:* second argument is the year. Tag format: project:id:year";
}
$year = $_[5];
$year = $_[4];
}
else {
$year = LDAP::get_year;
@ -141,7 +141,7 @@ sub tag_defense
# Determine full tag
my $long_tag;
{
my $proj_id = $_[3] // "";
my $proj_id = $_[2] // "";
$long_tag = "defense,$version,$proj_id,$path,$year";
}