Get git commit hash even if the repo only points to a bare repo.
* Used by https://github.com/debops/ansible-etherpad
This commit is contained in:
parent
83597562c1
commit
29441a8ae1
|
@ -218,8 +218,14 @@ exports.getGitCommit = function() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rootPath = path.resolve(npm.dir, '..');
|
var rootPath = path.resolve(npm.dir, '..');
|
||||||
var ref = fs.readFileSync(rootPath + "/.git/HEAD", "utf-8");
|
if (fs.lstatSync(rootPath + '/.git').isFile()) {
|
||||||
var refPath = rootPath + "/.git/" + ref.substring(5, ref.indexOf("\n"));
|
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 = fs.readFileSync(refPath, "utf-8");
|
||||||
version = version.substring(0, 7);
|
version = version.substring(0, 7);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue