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 ...@@ -558,23 +558,25 @@ class AuthenticationController
public function getGitRepoInformation(Request $request, Response $response) public function getGitRepoInformation(Request $request, Response $response)
{ {
if (!file_exists('package.json')) { $url = null;
return $response->withJson(['url' => null]);
} if (file_exists('package.json')) {
$license = json_decode(file_get_contents('package.json'), true);
$license = json_decode(file_get_contents('package.json'), true);
if (!empty($license['license'])) {
if (empty($license) || empty($license['license'])) { switch (strtolower($license['license'])) {
return $response->withJson(['url' => null]); case 'gpl-3.0':
} $url = 'https://labs.maarch.org/maarch/MaarchParapheur';
break;
if ($license['license'] == "GPL-3.0") { case 'maarch':
return $response->withJson(['url' => "https://labs.maarch.org/maarch/MaarchParapheur"]); $url = 'https://labs.maarch.org/maarch/MaarchParapheurPro';
} elseif (strtolower($license['license']) == "maarch") { break;
return $response->withJson(['url' => "https://labs.maarch.org/maarch/MaarchParapheurPro"]); default:
} else { break;
return $response->withJson(['url' => null]); }
}
} }
return $response->withJson(['url' => $url]);
} }
public function getGitCommitInformation(Request $request, Response $response) public function getGitCommitInformation(Request $request, Response $response)
...@@ -588,8 +590,14 @@ class AuthenticationController ...@@ -588,8 +590,14 @@ class AuthenticationController
if ($head === false) { if ($head === false) {
return $response->withJson(['hash' => null]); 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)) { if (empty($currentHead)) {
return $response->withJson(['hash' => null]); 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