From 1a3fa7e0f1b33998dad24c32868f3c37bcd23486 Mon Sep 17 00:00:00 2001 From: Dima Sabanin Date: Thu, 17 May 2018 13:45:00 -0400 Subject: [PATCH 1/2] Fix return type for Reference.isHead (typed as boolean, but returns a number) Both API docs and TypeScript typings say that Reference.isHead returns boolean, while in fact it's just a wrapper around Branch.isHead that returns 0 for false, 1 for true. This change makes the code do what published API already says it does. Branch.isHead is correctly typed in API as returning number. --- lib/reference.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reference.js b/lib/reference.js index 8cfdded6c..76d4dde56 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -37,7 +37,7 @@ Reference.prototype.isConcrete = function() { * @return {bool} */ Reference.prototype.isHead = function() { - return Branch.isHead(this); + return Branch.isHead(this) === 1; }; /** From e2ae1a92f2c0a22a2fa95a9bea8d78dabe67fee7 Mon Sep 17 00:00:00 2001 From: Dima Sabanin Date: Thu, 17 May 2018 13:50:00 -0400 Subject: [PATCH 2/2] Make isHead() test more strict about the return value. --- test/tests/branch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/branch.js b/test/tests/branch.js index 3900e4242..1db2d5cba 100644 --- a/test/tests/branch.js +++ b/test/tests/branch.js @@ -61,7 +61,7 @@ describe("Branch", function() { return repo.getBranch("master") .then(function(branch) { - assert.ok(branch.isHead()); + assert.strictEqual(branch.isHead(), true); }); });