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 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');
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: