Ensure that git head is really a file (and not a dir)

This commit is contained in:
Jan Böhmer 2020-03-30 14:57:16 +02:00
parent 95d06504ab
commit 1a0e07fbaf

View file

@ -60,7 +60,7 @@ class GitVersionInfo
*/
public function getGitBranchName()
{
if (file_exists($this->project_dir.'/.git/HEAD')) {
if (is_file($this->project_dir.'/.git/HEAD')) {
$git = file($this->project_dir.'/.git/HEAD');
$head = explode('/', $git[0], 3);
@ -86,7 +86,7 @@ class GitVersionInfo
public function getGitCommitHash(int $length = 7)
{
$filename = $this->project_dir.'/.git/refs/remotes/origin/'.$this->getGitBranchName();
if (file_exists($filename)) {
if (is_file($filename)) {
$head = file($filename);
if (! isset($head[0])) {