aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Porteneuve <[email protected]>2013-11-15 08:33:28 +0100
committerChristophe Porteneuve <[email protected]>2013-11-15 08:33:28 +0100
commit85c6bee0f6150e345f78f609b9728f82b704874f (patch)
treee7af9513b7620a86595277ff8149c2b58e4fbfe3
parentab2fb6f01063dd5dd6253a2a46d0f61e5f27092e (diff)
downloadnode-coveralls-85c6bee0f6150e345f78f609b9728f82b704874f.tar.xz
node-coveralls-85c6bee0f6150e345f78f609b9728f82b704874f.zip
Fix getOptions test for regular-case detached head state (e.g. Travis)
-rw-r--r--test/getOptions.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/getOptions.js b/test/getOptions.js
index bab5499..4b830be 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -308,7 +308,7 @@ function ensureLocalGitContext(options) {
options = options || {};
var synthetic = '/' === dir;
- var gitHead, branch, id, wrapUp = function() {};
+ var gitHead, content, branch, id, wrapUp = function() {};
if (synthetic) {
branch = 'synthetic';
@@ -340,8 +340,8 @@ function ensureLocalGitContext(options) {
};
} else if (options.detached) {
gitHead = path.join(gitDir, 'HEAD');
- var content = fs.readFileSync(gitHead, 'utf-8').trim();
- var b = content.match(/^ref: refs\/heads\/(\S+)$/)[1];
+ ontent = fs.readFileSync(gitHead, 'utf-8').trim();
+ var b = (content.match(/^ref: refs\/heads\/(\S+)$/) || [])[1];
if (!b) {
id = b;
} else {
@@ -352,8 +352,9 @@ function ensureLocalGitContext(options) {
};
}
} else {
- branch = fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf-8').trim().match(/^ref: refs\/heads\/(\S+)$/)[1];
- id = fs.readFileSync(path.join(gitDir, 'refs', 'heads', branch), 'utf-8').trim();
+ content = fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf-8').trim();
+ branch = (content.match(/^ref: refs\/heads\/(\S+)$/) || [])[1];
+ id = branch ? fs.readFileSync(path.join(gitDir, 'refs', 'heads', branch), 'utf-8').trim() : content;
}
return { id: id, branch: branch, wrapUp: wrapUp };