diff options
author | John McLear <john@mclear.co.uk> | 2015-10-22 16:13:58 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-10-22 16:13:58 +0100 |
commit | 3aff0001a1eaf4fa403213526cfccdbc9a73b097 (patch) | |
tree | 87af56a84058d6f30fbf983413992bc0dc6c2cbe /src/node/utils | |
parent | 50171a4c3c3a580a3136a9939902cd411775d323 (diff) | |
parent | 29441a8ae156113ebc50d8a655b3bf3a93c80db3 (diff) | |
download | etherpad-lite-3aff0001a1eaf4fa403213526cfccdbc9a73b097.zip |
Merge pull request #2798 from ypid/fixed_get_git_hash
Get git commit hash even if the repo only points to a bare repo.
Diffstat (limited to 'src/node/utils')
-rw-r--r-- | src/node/utils/Settings.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index ec327fb6..f76cebdc 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -228,8 +228,14 @@ exports.getGitCommit = function() { try { var rootPath = path.resolve(npm.dir, '..'); - var ref = fs.readFileSync(rootPath + "/.git/HEAD", "utf-8"); - var refPath = rootPath + "/.git/" + ref.substring(5, ref.indexOf("\n")); + if (fs.lstatSync(rootPath + '/.git').isFile()) { + rootPath = fs.readFileSync(rootPath + '/.git', "utf8"); + rootPath = rootPath.split(' ').pop().trim(); + } else { + 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"); version = version.substring(0, 7); } |