Archived
1
0
Fork 0

Start moulette_get process

This commit is contained in:
Mercier Pierre-Olivier 2013-09-20 03:35:53 +02:00
parent 42a73c9031
commit a5fb66040b
2 changed files with 198 additions and 0 deletions

View file

@ -163,6 +163,8 @@ sub tag_defense
# TODO: check user permissions
# TODO: check presence in project.xml
# Generate questions and answer id
my $defense = Defense->new(\$content);
$defense->genIds();
@ -352,7 +354,112 @@ sub tag_project
sub tag_ref
{
my $creation = shift;
# From here, we have:
# 1: "ref"
# 2: $id
# 3: rendu-X
# 4: $year
my $project_id = repository_name();
if ($_[2]) {
# Check on ID/flavour_id
if ($_[2] =~ /^\d+$/) {
log ERROR, "ref,* tag can't take version. Tag format: ref,id,rendu,year";
}
$project_id .= "-" . $_[2];
}
$project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g;
my $rendu;
if ($_[3]) {
$rendu = $_[3];
}
else {
$rendu = "*";
}
my $year;
if ($_[4]) {
# Check on year
if ($_[4] !~ /^\d+$/) {
log ERROR, "ref,*,*,* third argument is the year. Tag format: ref,id,rendu,year";
}
$year = $_[4];
}
else {
$year = LDAP::get_year;
}
# Determine full tag
my $long_tag;
{
my $proj_id = $_[2] // "";
$long_tag = "ref,$proj_id,$rendu,$year";
}
if ($creation)
{
my $newref = $ARGV[2];
log INFO, "Création/mise à jour de la ref...";
my $content = qx(git show $newref:ref/Makefile);
# Check file exists
if ($?) {
log ERROR, "Un fichier Makefile est requis pour pouvoir compiler et exécuter la ref.";
}
log INFO, "Création de la tarball...";
my $archive = qx(git archive --format=tgz $newref ref/);
# Send data to moulette
log INFO, "Attente d'un processus de compilation...";
if (my $err = Process::Client::launch("moulette_get", {
type => "ref",
id => $project_id,
"year" => $year,
"rendu" => $rendu,
"file" => "ref_$rendu.tgz"
}, { "ref_$rendu.tgz" => $archive }))
{
if (${ $err } ne "Ok") {
log ERROR, "Erreur durant le processus de compilation : " . ${ $err };
}
}
if ($long_tag)
{
qx(git tag -f $long_tag);
if (! $?) {
log INFO, "Tag long créé : $long_tag.";
}
}
}
else
{
# Is the long tag existing
qx(git tag | egrep "^$long_tag\$");
if ($?) {
log ERROR, "Tag long correspondant introuvable : $long_tag.";
}
log USAGE, "Suppression du projet !";
if ($long_tag)
{
qx(git tag -d $long_tag);
if (! $?) {
log INFO, "Tag long supprimé : $long_tag.";
}
}
}
}
sub tag_tests