utils: Fix commit checking on detached HEAD

This commit is contained in:
Andrew Dassonville 2020-10-22 15:05:12 -07:00 committed by Richard Hansen
parent cb5fcbb74e
commit bee1ae06d8

View file

@ -423,8 +423,12 @@ exports.getGitCommit = function() {
rootPath += '/.git';
}
var ref = fs.readFileSync(rootPath + "/HEAD", "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)