Preserve token between two commit
This commit is contained in:
parent
01b8f4327a
commit
78d733669f
1 changed files with 28 additions and 2 deletions
|
@ -261,8 +261,6 @@ sub tag_project
|
|||
{
|
||||
my $newref = $ARGV[2];
|
||||
|
||||
log INFO, "Création/mise à jour du projet...";
|
||||
|
||||
my $content = qx(git show $newref:project.xml);
|
||||
# Check file exists
|
||||
if ($?) {
|
||||
|
@ -276,6 +274,19 @@ sub tag_project
|
|||
|
||||
# TODO: check user permissions
|
||||
|
||||
# Project already online?
|
||||
my $project;
|
||||
eval {
|
||||
$project = API::Project::get($project_id, $year);
|
||||
};
|
||||
|
||||
if ($project) {
|
||||
log INFO, "Mise à jour du projet $project_id";
|
||||
}
|
||||
else {
|
||||
log INFO, "Création du projet $project_id";
|
||||
}
|
||||
|
||||
# Generate token for VCS submission
|
||||
my $dom = XML::LibXML->load_xml(string => (\$content));
|
||||
my $mod = 0;
|
||||
|
@ -283,6 +294,21 @@ sub tag_project
|
|||
{
|
||||
if (! $vcs->hasAttribute("token"))
|
||||
{
|
||||
if ($project)
|
||||
{
|
||||
# Looking for an old token
|
||||
my @rendus = grep {
|
||||
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
||||
} @{ $project->{submissions} };
|
||||
|
||||
if (@rendus == 1) {
|
||||
log INFO, "Use existing token: ".$rendus[0]->{vcs}{token};
|
||||
$vcs->setAttribute("token", substr($rendus[0]->{vcs}{token}, 2, 23));
|
||||
$mod = 1;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
my $token;
|
||||
do {
|
||||
$token = sha1_base64(rand);
|
||||
|
|
Reference in a new issue