From bad4dd3766837c483a7fad39108653d822b69697 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 18 Sep 2013 07:53:50 +0200 Subject: [PATCH] Start defense tag hook --- hooks/subjects.pl | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index a94380e..89c2c16 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -74,7 +74,73 @@ sub repository_name sub tag_defense { + my $creation = shift; + # From here, we have: + # 1: "defense" + # 2: $version + # 3: $id + # 4: $path + # 5: $year + + my $version = $_[3] // 1; + + my $project_id = repository_name(); + if ($_[3]) + { + # Check on ID/flavour_id + if ($_[3] =~ /^\d+$/) { + log ERROR, "defense:* tag can't take version. Tag format: defense:version:id:year"; + } + + $project_id .= "-" . $_[3]; + } + $project_id = lc $project_id; + $project_id =~ s/[^a-z0-9-_]/_/g; + + + my $year; + if ($_[5]) + { + # Check on year + if ($_[5] !~ /^\d+$/) { + log ERROR, "project:*:* second argument is the year. Tag format: project:id:year"; + } + + $year = $_[5]; + } + else { + $year = LDAP::get_year; + } + + if ($creation) + { + 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); + # Check file exists + if ($?) { + log ERROR, "Créez un fichier project.xml à la racine du dépôt."; + } + + # 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."; + } + + # TODO: check user permissions + } } sub tag_document