[Pkg-javascript-commits] [node-coveralls] 110/332: Fix getOptions test for regular-case detached head state (e.g. Travis)

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 85c6bee0f6150e345f78f609b9728f82b704874f
Author: Christophe Porteneuve <tdd at tddsworld.com>
Date:   Fri Nov 15 08:33:28 2013 +0100

    Fix getOptions test for regular-case detached head state (e.g. Travis)
---
 test/getOptions.js | 11 ++++++-----
 1 file 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 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list