From 62b7395625ea31cd3d25a133163612a96de65f8a Mon Sep 17 00:00:00 2001 From: WJXHenry Date: Thu, 2 May 2019 18:58:35 -0600 Subject: [PATCH 1/3] modified 'listCommits' test with no options --- test/repository.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repository.spec.js b/test/repository.spec.js index 62bb3ba6..a8a05a7c 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -121,7 +121,7 @@ describe('Repository', function() { }); it('should list commits with no options', function(done) { - remoteRepo.listCommits(null, assertSuccessful(done, function(err, commits) { + remoteRepo.listCommits(assertSuccessful(done, function(err, commits) { expect(commits).to.be.an.array(); expect(commits.length).to.be.above(0); From 9f558aa5d90aed1b997c00902c1dda043b25d609 Mon Sep 17 00:00:00 2001 From: WJXHenry Date: Thu, 2 May 2019 19:09:21 -0600 Subject: [PATCH 2/3] fix 'listCommits' when only callback is given --- lib/Repository.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Repository.js b/lib/Repository.js index f59cf0d0..5c8eb7ff 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -187,8 +187,10 @@ class Repository extends Requestable { * @return {Promise} - the promise for the http request */ listCommits(options, cb) { - options = options || {}; - + if (typeof options === 'function') { + cb = options; + options = {}; + } options.since = this._dateToISO(options.since); options.until = this._dateToISO(options.until); From f2cfa935ade542a3f552495635fb1f7f3f3b8ce1 Mon Sep 17 00:00:00 2001 From: WJXHenry Date: Sat, 4 May 2019 17:00:45 -0600 Subject: [PATCH 3/3] Re-added test and default value setting for options --- lib/Repository.js | 1 + test/repository.spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/Repository.js b/lib/Repository.js index 5c8eb7ff..8cf23dc2 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -187,6 +187,7 @@ class Repository extends Requestable { * @return {Promise} - the promise for the http request */ listCommits(options, cb) { + options = options || {}; if (typeof options === 'function') { cb = options; options = {}; diff --git a/test/repository.spec.js b/test/repository.spec.js index a8a05a7c..dceeffac 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -132,6 +132,18 @@ describe('Repository', function() { })); }); + it('should list commits with null options', function(done) { + remoteRepo.listCommits(null, assertSuccessful(done, function(err, commits) { + expect(commits).to.be.an.array(); + expect(commits.length).to.be.above(0); + + expect(commits[0]).to.have.own('commit'); + expect(commits[0]).to.have.own('author'); + + done(); + })); + }); + it('should list commits with all options', function(done) { const since = new Date(2015, 0, 1); const until = new Date(2016, 0, 20);