Tag defense,... done
This commit is contained in:
parent
bad4dd3766
commit
951470b06b
8 changed files with 601 additions and 232 deletions
|
@ -7,6 +7,7 @@ use Digest::SHA qw(sha1_base64);
|
|||
use File::Basename;
|
||||
|
||||
use ACU::API::Projects;
|
||||
use ACU::Defense;
|
||||
use ACU::LDAP;
|
||||
use ACU::Log;
|
||||
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
|
||||
|
@ -83,7 +84,7 @@ sub tag_defense
|
|||
# 4: $path
|
||||
# 5: $year
|
||||
|
||||
my $version = $_[3] // 1;
|
||||
my $version = $_[2] // 1;
|
||||
|
||||
my $project_id = repository_name();
|
||||
if ($_[3])
|
||||
|
@ -97,7 +98,37 @@ sub tag_defense
|
|||
}
|
||||
$project_id = lc $project_id;
|
||||
$project_id =~ s/[^a-z0-9-_]/_/g;
|
||||
|
||||
|
||||
my $path;
|
||||
if ($_[4])
|
||||
{
|
||||
if ($_[4] =~ /(?:defenses\/)?([a-zA-Z0-9\/]+)(?:.xml)/) {
|
||||
$path = "defenses/".$1.".xml";
|
||||
} else {
|
||||
$path = $_[4];
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Looking for an uniq defense file in defenses/
|
||||
$path = qx(git ls-tree -r --name-only HEAD defenses/ | egrep '\.xml\$');
|
||||
my $nb_defenses = $path =~ tr/\n//;
|
||||
if ($nb_defenses > 1) {
|
||||
log ERROR, "Veuillez préciser le chemin de la soutenance à utiliser";
|
||||
exit 1;
|
||||
}
|
||||
elsif ($nb_defenses == 0) {
|
||||
log ERROR, "Aucune soutenance n'a été trouvée dans le dossier defenses/";
|
||||
exit 1;
|
||||
}
|
||||
chomp($path);
|
||||
}
|
||||
|
||||
my $defense_id;
|
||||
if ($_[4] =~ /(?:defenses\/)?([a-zA-Z0-9\/]+)(?:.xml)/) {
|
||||
$defense_id = $1;
|
||||
} else {
|
||||
log ERROR, "Déplacez votre soutenance dans le dossier defenses ou simplifiez le nom du fichier.";
|
||||
}
|
||||
|
||||
my $year;
|
||||
if ($_[5])
|
||||
|
@ -117,40 +148,44 @@ sub tag_defense
|
|||
{
|
||||
my $newref = $ARGV[2];
|
||||
|
||||
my $path;
|
||||
if ($_[4]) {
|
||||
$path = $_[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
log INFO, "Création/mise à jour de la soutenance...";
|
||||
|
||||
my $content = qx(git show $newref:project.xml);
|
||||
log INFO, "Looking for $path...";
|
||||
# Check file exists
|
||||
my $content = qx(git show $newref:$path);
|
||||
if ($?) {
|
||||
log ERROR, "Créez un fichier project.xml à la racine du dépôt.";
|
||||
log ERROR, "Impossible de trouver la soutenance.";
|
||||
}
|
||||
|
||||
# Check DTD validity
|
||||
if (check_xml(\$content, "http://acu.epita.fr/dtd/defense.dtd")) {
|
||||
log ERROR, "Corrigez les erreurs du fichier XXX.xml avant de lancer la création du projet.";
|
||||
log ERROR, "Corrigez les erreurs du fichier $path avant de publier la soutenance.";
|
||||
}
|
||||
|
||||
# TODO: check user permissions
|
||||
|
||||
# Generate questions and answer id
|
||||
my $defense = Defense->new(\$content);
|
||||
$defense->genIds();
|
||||
|
||||
# Send data to intradata
|
||||
log INFO, "Attente d'un processus de publication...";
|
||||
if (my $err = Process::Client::launch("intradata_get", { action => "update", type => "defense", id => $project_id, "year" => $year, "defense_id" => $defense_id, "version" => $version }, { "$defense_id.xml" => $defense->toString() }))
|
||||
{
|
||||
if (${ $err } ne "Ok") {
|
||||
log ERROR, "Erreur durant le processus de publication : " . ${ $err };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sub tag_document
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub tag_grades
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub tag_project
|
||||
|
@ -293,10 +328,10 @@ sub tag_project
|
|||
|
||||
sub tag_ref
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub tag_tests
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue