Split out git common dir detection to handle file_get_contents error cases
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
parent
cb141f2092
commit
4c99a7d8f8
@ -497,6 +497,19 @@ class Git
|
||||
return [$hash, $branch];
|
||||
}
|
||||
|
||||
private function getCommonDirContents(string $gitFolder): ?string
|
||||
{
|
||||
if (! is_file($gitFolder . '/commondir')) {
|
||||
return null;
|
||||
}
|
||||
$commonDirContents = @file_get_contents($gitFolder . '/commondir');
|
||||
if ($commonDirContents === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim($commonDirContents);
|
||||
}
|
||||
|
||||
/**
|
||||
* detects Git revision, if running inside repo
|
||||
*/
|
||||
@ -518,10 +531,9 @@ class Git
|
||||
return null;
|
||||
}
|
||||
|
||||
$common_dir_contents = @file_get_contents($gitFolder . '/commondir');
|
||||
|
||||
if ($common_dir_contents !== false) {
|
||||
$gitFolder .= DIRECTORY_SEPARATOR . trim($common_dir_contents);
|
||||
$commonDirContents = $this->getCommonDirContents($gitFolder);
|
||||
if ($commonDirContents !== null) {
|
||||
$gitFolder .= DIRECTORY_SEPARATOR . $commonDirContents;
|
||||
}
|
||||
|
||||
[$hash, $branch] = $this->getHashFromHeadRef($gitFolder, $ref_head);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user