File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments