New hooks version: allow ACU-* tags
This commit is contained in:
parent
868324e6e2
commit
45ba55a416
@ -30,25 +30,14 @@ exit(0) if (!$promo || !$id_project || !$repo_login);
|
|||||||
|
|
||||||
for my $ref (@ARGV)
|
for my $ref (@ARGV)
|
||||||
{
|
{
|
||||||
if ($ref =~ m<^refs/tags/(.+)$>)
|
if ($ref =~ m<^refs/tags/ACU-(.+)$> || $ref =~ m<^refs/tags/(.+)$>)
|
||||||
{
|
{
|
||||||
my $tag = $1;
|
my $tag = $1;
|
||||||
log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated.";
|
log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated.";
|
||||||
|
|
||||||
# Get project informations
|
my $project = get_project_info($tag);
|
||||||
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 ; si le problème persiste, passez au laboratoire.";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Extract lot of data
|
# Extract matching tag
|
||||||
my @rendus = grep {
|
my @rendus = grep {
|
||||||
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
||||||
} @{ $project->{submissions} };
|
} @{ $project->{submissions} };
|
||||||
@ -77,14 +66,14 @@ for my $ref (@ARGV)
|
|||||||
|
|
||||||
# Send data to API
|
# Send data to API
|
||||||
my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`;
|
my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`;
|
||||||
eval {
|
eval {
|
||||||
API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit);
|
API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit);
|
||||||
};
|
};
|
||||||
if ($@)
|
if ($@)
|
||||||
{
|
{
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
log DEBUG, "ERROR: ".$err;
|
log DEBUG, "ERROR: ".$err;
|
||||||
log DONE, "Tag '$tag' effectué avec succès !";
|
log DONE, "Tag '$tag' effectué avec succès !";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet.";
|
log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet.";
|
||||||
@ -94,3 +83,22 @@ for my $ref (@ARGV)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
sub get_project_info
|
||||||
|
{
|
||||||
|
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 ; si le problème persiste, passez au laboratoire.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
log TRACE, $project;
|
||||||
|
|
||||||
|
return $project;
|
||||||
|
}
|
||||||
|
@ -38,12 +38,68 @@ $repo_login = $1 if (!$repo_login && $ENV{'GL_REPO'} =~ m/.*\/.*\/(.*)/);
|
|||||||
|
|
||||||
exit(0) if (!$promo || !$id_project || !$repo_login);
|
exit(0) if (!$promo || !$id_project || !$repo_login);
|
||||||
|
|
||||||
if ($ref =~ m<^refs/tags/(.+)$>)
|
if ($ref =~ m<^refs/tags/ACU-(.+)$>)
|
||||||
{
|
{
|
||||||
my $tag = $1;
|
my $tag = $1;
|
||||||
log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}";
|
log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}";
|
||||||
|
|
||||||
# Get project informations
|
# Disallow no ACU
|
||||||
|
if ($ENV{GL_USER} ne "frotti_b" && $ENV{GL_USER} ne "chen_a" && $ENV{GL_USER} ne "boisse_r" && $ENV{GL_USER} ne "genite_n" && $ENV{GL_USER} ne "mercie_d")
|
||||||
|
{
|
||||||
|
log ERROR, "Vous n'êtes pas autorisé à envoyer ce tag.";
|
||||||
|
exit(9);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $project = get_project_info($tag);
|
||||||
|
|
||||||
|
# Extract matching tag
|
||||||
|
my @rendus = grep {
|
||||||
|
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
||||||
|
} @{ $project->{submissions} };
|
||||||
|
|
||||||
|
if (! @rendus)
|
||||||
|
{
|
||||||
|
log ERROR, "$tag n'est pas un tag valide.";
|
||||||
|
exit(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($ref =~ m<^refs/tags/(.+)$>)
|
||||||
|
{
|
||||||
|
my $tag = $1;
|
||||||
|
log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}";
|
||||||
|
|
||||||
|
my $project = get_project_info($tag);
|
||||||
|
|
||||||
|
# Extract matching tag
|
||||||
|
my @rendus = grep {
|
||||||
|
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
||||||
|
} @{ $project->{submissions} };
|
||||||
|
|
||||||
|
if (@rendus)
|
||||||
|
{
|
||||||
|
if ($newsha eq '0' x 40)
|
||||||
|
{
|
||||||
|
log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!";
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`);
|
||||||
|
if (! check_submission_date($tokengiven, @rendus))
|
||||||
|
{
|
||||||
|
exit (9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log ERROR, "$tag n'est pas un tag valide.";
|
||||||
|
exit(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
||||||
|
sub get_project_info
|
||||||
|
{
|
||||||
my $project;
|
my $project;
|
||||||
eval {
|
eval {
|
||||||
$project = API::Projects::get($id_project, $promo);
|
$project = API::Projects::get($id_project, $promo);
|
||||||
@ -58,10 +114,12 @@ if ($ref =~ m<^refs/tags/(.+)$>)
|
|||||||
|
|
||||||
log TRACE, $project;
|
log TRACE, $project;
|
||||||
|
|
||||||
# Extract lot of data
|
return $project;
|
||||||
my @rendus = grep {
|
}
|
||||||
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
|
||||||
} @{ $project->{submissions} };
|
sub check_submission_date
|
||||||
|
{
|
||||||
|
my $tokengiven = shift;
|
||||||
|
|
||||||
my $glts = DateTime::Format::ISO8601->parse_datetime(
|
my $glts = DateTime::Format::ISO8601->parse_datetime(
|
||||||
do {
|
do {
|
||||||
@ -70,34 +128,16 @@ if ($ref =~ m<^refs/tags/(.+)$>)
|
|||||||
$t
|
$t
|
||||||
});
|
});
|
||||||
|
|
||||||
chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`);
|
for my $rendu (@_)
|
||||||
for my $rendu (@rendus)
|
|
||||||
{
|
{
|
||||||
my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin});
|
my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin});
|
||||||
my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end});
|
my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end});
|
||||||
|
|
||||||
if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping)
|
# if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping)
|
||||||
{
|
# {
|
||||||
$open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00");
|
# $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00");
|
||||||
$close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00");
|
# $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00");
|
||||||
}
|
# }
|
||||||
elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonS)
|
|
||||||
{
|
|
||||||
$open = DateTime::Format::ISO8601->parse_datetime("2013-11-24T09:00:00");
|
|
||||||
$close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T21:00:00");
|
|
||||||
}
|
|
||||||
elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonD)
|
|
||||||
{
|
|
||||||
$open = DateTime::Format::ISO8601->parse_datetime("2013-11-23T21:00:00");
|
|
||||||
}
|
|
||||||
elsif ($id_project eq "logomatig" && "dufour_h" eq $repo_login)
|
|
||||||
{
|
|
||||||
$close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T16:42:00");
|
|
||||||
}
|
|
||||||
elsif ($id_project eq "42sh" && "hadjad_r" eq $repo_login)
|
|
||||||
{
|
|
||||||
$close = DateTime::Format::ISO8601->parse_datetime("2013-12-01T17:42:00");
|
|
||||||
}
|
|
||||||
|
|
||||||
say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S");
|
say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S");
|
||||||
|
|
||||||
@ -124,13 +164,5 @@ if ($ref =~ m<^refs/tags/(.+)$>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@rendus && $newsha eq '0' x 40)
|
return 1;
|
||||||
{
|
|
||||||
log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!";
|
|
||||||
exit(7);
|
|
||||||
}
|
|
||||||
# elsif @rendus : new rendu => accepted
|
|
||||||
# else user defined tag => accepted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
|
||||||
|
Reference in New Issue
Block a user