summaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorRobin Schneider <ypid@riseup.net>2015-10-07 15:43:29 +0200
committerRobin Schneider <ypid@riseup.net>2015-10-07 15:43:29 +0200
commit29441a8ae156113ebc50d8a655b3bf3a93c80db3 (patch)
tree88757eb18244599c0022a6b9ea402a7081b42bc8 /src/node
parent83597562c1dd8f9d284cc68a8a94b63cdac039a1 (diff)
downloadetherpad-lite-29441a8ae156113ebc50d8a655b3bf3a93c80db3.zip
Get git commit hash even if the repo only points to a bare repo.
* Used by https://github.com/debops/ansible-etherpad
Diffstat (limited to 'src/node')
-rw-r--r--src/node/utils/Settings.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js
index 2c2f90bf..e1825ef4 100644
--- a/src/node/utils/Settings.js
+++ b/src/node/utils/Settings.js
@@ -218,8 +218,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);
}