Skip to content
Snippets Groups Projects
Commit 806b6472 authored by Jean-Laurent DUZANT's avatar Jean-Laurent DUZANT
Browse files

FIX #24074 TIME 0:45 improve getGitRepoInformation function && fix hash bug,...

FIX #24074 TIME 0:45 improve getGitRepoInformation function && fix hash bug, when tag is in 'detached HEAD'
parent 3f655a03
No related branches found
No related tags found
No related merge requests found
......@@ -558,23 +558,25 @@ class AuthenticationController
public function getGitRepoInformation(Request $request, Response $response)
{
if (!file_exists('package.json')) {
return $response->withJson(['url' => null]);
}
$license = json_decode(file_get_contents('package.json'), true);
if (empty($license) || empty($license['license'])) {
return $response->withJson(['url' => null]);
}
if ($license['license'] == "GPL-3.0") {
return $response->withJson(['url' => "https://labs.maarch.org/maarch/MaarchParapheur"]);
} elseif (strtolower($license['license']) == "maarch") {
return $response->withJson(['url' => "https://labs.maarch.org/maarch/MaarchParapheurPro"]);
} else {
return $response->withJson(['url' => null]);
$url = null;
if (file_exists('package.json')) {
$license = json_decode(file_get_contents('package.json'), true);
if (!empty($license['license'])) {
switch (strtolower($license['license'])) {
case 'gpl-3.0':
$url = 'https://labs.maarch.org/maarch/MaarchParapheur';
break;
case 'maarch':
$url = 'https://labs.maarch.org/maarch/MaarchParapheurPro';
break;
default:
break;
}
}
}
return $response->withJson(['url' => $url]);
}
public function getGitCommitInformation(Request $request, Response $response)
......@@ -588,8 +590,14 @@ class AuthenticationController
if ($head === false) {
return $response->withJson(['hash' => null]);
}
preg_match('#^ref:(.+)$#', $head, $matches);
$currentHead = trim($matches[1]);
if (preg_match('#^ref:(.+)$#', $head, $matches)) {
// The HEAD file contains a reference to a branch
$currentHead = trim($matches[1]);
} else {
// The HEAD file contains a hash
return $response->withJson(['hash' => trim($head)]);
}
if (empty($currentHead)) {
return $response->withJson(['hash' => null]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment