From bee1ae06d8239433e0a457796c8f60b69ff47378 Mon Sep 17 00:00:00 2001 From: Andrew Dassonville Date: Thu, 22 Oct 2020 15:05:12 -0700 Subject: [PATCH] utils: Fix commit checking on detached HEAD --- src/node/utils/Settings.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index ee84f4b8..b1296068 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -423,8 +423,12 @@ exports.getGitCommit = function() { rootPath += '/.git'; } var ref = fs.readFileSync(rootPath + "/HEAD", "utf-8"); - var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n")); - version = fs.readFileSync(refPath, "utf-8"); + if (ref.startsWith("ref: ")) { + var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n")); + version = fs.readFileSync(refPath, "utf-8"); + } else { + version = ref; + } version = version.substring(0, 7); } catch(e) { console.warn("Can't get git version for server header\n" + e.message)