From f06590a642b93d10559aa8be84200bc58d2bdeba Mon Sep 17 00:00:00 2001 From: Thomas David Baker Date: Tue, 26 Nov 2024 11:32:43 -0800 Subject: [PATCH] Handle a detatched head state when looking for git hash --- gatherling/bootstrap.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gatherling/bootstrap.php b/gatherling/bootstrap.php index d0f4d6aa5..38e6b2924 100644 --- a/gatherling/bootstrap.php +++ b/gatherling/bootstrap.php @@ -24,8 +24,13 @@ $CONFIG['GIT_HASH'] = null; if (file_exists('../.git/HEAD')) { $branch = trim(substr(file_get_contents('../.git/HEAD'), 5)); - if ($hash = file_get_contents(sprintf('../.git/%s', $branch))) { - $CONFIG['GIT_HASH'] = $hash; + $hash_file = sprintf('../.git/%s', $branch); + if (file_exists($hash_file)) { + // On a branch, get the hash + $CONFIG['GIT_HASH'] = file_get_contents($hash_file); + } else { + // On a detached HEAD, just use the branch name + $CONFIG['GIT_HASH'] = $branch; } }