Skip to content

Commit 8650200

Browse files
author
simbabimba-dev
committed
Revert "fix: 🐛 handle empty or unreadable .git/HEAD file"
This reverts commit 32334b0.
1 parent 61225d9 commit 8650200

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

app/Providers/AppServiceProvider.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public function boot()
6767

6868
// get the Git branch and commit the panel is running on
6969
$headFileMissing = false;
70-
$branchname = 'unknown';
71-
$commitHash = 'unknown';
7270

7371
try {
7472
$headFilePath = base_path() . '/.git/HEAD';
@@ -77,12 +75,7 @@ public function boot()
7775
throw new Exception('.git/HEAD file not found');
7876
}
7977

80-
$fileContent = file($headFilePath);
81-
if (!$fileContent || empty($fileContent[0])) {
82-
throw new Exception('.git/HEAD file is empty or unreadable');
83-
}
84-
85-
$firstLine = trim($fileContent[0]);
78+
$firstLine = trim(file($headFilePath)[0]);
8679
// branch ref in HEAD is format "ref: refs/heads/branchname"
8780
if (str_starts_with($firstLine, 'ref:')) {
8881
$branchname = basename(trim(str_replace('ref:', '', $firstLine)));
@@ -97,6 +90,8 @@ public function boot()
9790
$commitHash = $possibleCommit;
9891
}
9992
} catch (Exception $e) {
93+
$branchname = 'unknown';
94+
$commitHash = 'unknown';
10095
Log::notice($e);
10196
}
10297

0 commit comments

Comments
 (0)