Skip to content

Commit

Permalink
Change to double-quoted strings
Browse files Browse the repository at this point in the history
With single quotes ('\n'), the str_replace() function won't recognize it as a newline character. It will look for the literal sequence of a backslash followed by n, which I don't think we want.
  • Loading branch information
alexanderfrodeberg authored Jan 15, 2024
1 parent 7399124 commit 9535b6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Helpers/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Git
public static function getCommitHash(): ? string
{
try {
$branch = str_replace('\n', '', last(explode('/', (string)file_get_contents(base_path() . '/.git/HEAD'))));
$branch = str_replace("\n", '', last(explode('/', (string)file_get_contents(base_path() . '/.git/HEAD'))));
$hash = file_get_contents(base_path() . '/.git/refs/heads/' . $branch);
} catch (Exception $exception) {
throw new GitHashException($exception->getMessage(), previous: $exception);
Expand Down

0 comments on commit 9535b6f

Please sign in to comment.