From 95fb236fb18d03eee6e8e7abb0a291c3f20dc5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Cala=C3=A7a?= Date: Wed, 6 Nov 2019 18:51:13 -0300 Subject: [PATCH 1/2] improve(repository): add list commits on pull request function --- lib/Repository.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Repository.js b/lib/Repository.js index daf9443f..74452dde 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -198,6 +198,23 @@ class Repository extends Requestable { return this._request('GET', `/repos/${this.__fullname}/commits`, options, cb); } + /** + * List the commits on a pull request + * @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository + * @param {number|string} number - the number of the pull request to list the commits + * @param {Object} [options] - the filtering options for commits + * @param {Requestable.callback} [cb] - will receive the commits information + * @return {Promise} - the promise for the http request + */ + listCommitsOnPR(number, options, cb) { + options = options || {}; + if (typeof options === 'function') { + cb = options; + options = {}; + } + return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/commits`, options, cb); + } + /** * Gets a single commit information for a repository * @see https://developer.github.com/v3/repos/commits/#get-a-single-commit From ba74ee2196a48d619241691b27630b9d32bc8b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Cala=C3=A7a?= Date: Wed, 6 Nov 2019 18:52:15 -0300 Subject: [PATCH 2/2] test(repository): add specs to test the new listCommitsOnPR function --- test/repository.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/repository.spec.js b/test/repository.spec.js index 7102874b..2d71b04f 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -173,6 +173,24 @@ describe('Repository', function() { })); }); + it('should list commits on a PR with no options', function(done) { + const PR_NUMBER = 588; + remoteRepo.listCommitsOnPR(PR_NUMBER, assertSuccessful(done, function(err, commits) { + expect(commits).to.be.an.array(); + expect(commits.length).to.be.equal(2); + + let message1 = 'fix(repository): prevents lib from crashing when not providing optional arguments'; + expect(commits[0].author).to.have.own('login', 'hazmah0'); + expect(commits[0].commit).to.have.own('message', message1); + + let message2 = 'test(repository): updates test to use promise instead of callback'; + expect(commits[1].author).to.have.own('login', 'hazmah0'); + expect(commits[1].commit).to.have.own('message', message2); + + done(); + })); + }); + it('should get the latest commit from master', function(done) { remoteRepo.getSingleCommit('master', assertSuccessful(done, function(err, commit) { expect(commit).to.have.own('sha'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy