Start submission hook
This commit is contained in:
parent
fbef87cb09
commit
9210d07fda
3 changed files with 57 additions and 3 deletions
47
hooks/submissions.pl
Normal file
47
hooks/submissions.pl
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use v5.10;
|
||||
use Date::Manip;
|
||||
|
||||
use ACU::API::Projects;
|
||||
use ACU::API::Submission;
|
||||
use ACU::LDAP;
|
||||
use ACU::Log;
|
||||
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
|
||||
use ACU::Process;
|
||||
|
||||
# First, check if the repository is in the YYYY/ directory
|
||||
exit 0 if ($ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/);
|
||||
|
||||
my ($ref, $oldsha, $newsha) = @ARGV;
|
||||
|
||||
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";
|
||||
|
||||
# Get project informations
|
||||
my $project;
|
||||
eval {
|
||||
$project = API::Projects::get($id_project, $promo);
|
||||
};
|
||||
if ($@ or !$project) {
|
||||
my $err = $@;
|
||||
log TRACE, $err;
|
||||
log ERROR, "Impossible d'envoyer de tags. Passer au laboratoire si le problème persiste.";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
log TRACE, $project;
|
||||
}
|
||||
|
||||
exit 1;
|
||||
exit 0;
|
Reference in a new issue