Archived
1
0

Submissions Ok

This commit is contained in:
Mercier Pierre-Olivier 2013-09-16 07:09:23 +02:00
parent 0825ca12e0
commit 17ea229729
2 changed files with 22 additions and 13 deletions

View File

@ -18,11 +18,8 @@ sub add($$$$$)
my $res = API::Base::send('ResultHandler', "projects/submissions/add.xml", [ leader_login => $user, project_name => $project, year => $year, log => $log, tag => $tag ]);
if ($res->{result} == '0') {
say "Rendu ok";
}
else {
say "Rendu non ok : retour de l'API non nul.";
if ($res->{result} != '0') {
croak "Erreur durant le rendu : ".$res->{message};
}
}

View File

@ -22,12 +22,10 @@ my $promo = $1 if ($ENV{'GL_REPO'} =~ m/([0-9]{4}).*/);
my $id_project = $1 if ($ENV{'GL_REPO'} =~ m/.*\/(.*)\//);
my $repo_login = $1 if ($ENV{'GL_REPO'} =~ m/.*\/.*\/(.*)/);
log WARN, "This is a project!";
if ($ref =~ m<^refs/tags/(.+)$>)
{
my $tag = $1;
log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag";
log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag";
# Get project informations
my $project;
@ -52,7 +50,7 @@ if ($ref =~ m<^refs/tags/(.+)$>)
$date =~ s/\./ /;
my $glts = ParseDate($date);
chomp (my $tokengiven = `git cat-file tag $newsha | sed -e '1,/^\$/d'`);
chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`);
for my $rendu (@rendus)
{
my $open = ParseDate($rendu->{period}{begin});
@ -60,26 +58,40 @@ if ($ref =~ m<^refs/tags/(.+)$>)
# TODO: check exceptions by login/group
say "[ACU] Date courante: ", $glts;
say "[ACU] Date fermeture: ", $close;
if ((Date_Cmp($glts, $open) == -1))
{
print "[ACU] Tag not allowed: upload not yet opened!\n";
say "[ACU] Tag not allowed: upload not yet opened!";
exit(4);
}
if ((Date_Cmp($glts, $close) == 1))
{
print "[ACU] Tag not allowed: upload closed!\n";
say "[ACU] Tag not allowed: upload closed!";
exit(5);
}
my $token = $rendu->{vcs}{token};
if ($token ne "" and $token ne $tokengiven)
{
print "[ACU] Error 0x65cd58: Bad token.\n";
say "[ACU] Error 0x65cd58: Bad token.";
exit(6);
}
}
# Send data to API
my $last_commit = `git log -1 --name-status`;
eval {
API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit);
};
if ($@) {
my $err = $@;
log DEBUG, "ERROR: ".$err;
}
log DONE, "[ACU] UPLOAD successful, please check this information on the intranet";
}
exit 1;
exit 0;