From 21844cb7874040a44310bdb825db4306d60fc611 Mon Sep 17 00:00:00 2001 From: noansknv Date: Sun, 12 Feb 2017 20:08:20 -0800 Subject: [PATCH] Add Repository.listPullRequestCommits --- lib/Repository.js | 11 +++++++++++ test/repository.spec.js | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..1764f115 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -119,6 +119,17 @@ class Repository extends Requestable { return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/files`, null, cb); } + /** + * List the commits of a specific pull request + * @see https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + * @param {number|string} number - the PR you wish to fetch + * @param {Requestable.callback} [cb] - will receive the list of commits from the API + * @return {Promise} - the promise for the http request + */ + listPullRequestCommits(number, cb) { + return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/commits`, null, cb); + } + /** * Compare two branches/commits/repositories * @see https://developer.github.com/v3/repos/commits/#compare-two-commits diff --git a/test/repository.spec.js b/test/repository.spec.js index ef5101cf..1a07ebb2 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -14,6 +14,7 @@ describe('Repository', function() { let imageBlob; const testRepoName = getTestRepoName(); const v10SHA = '20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; + const testPRNumber = 153; const statusUrl = 'https://api.github.com/repos/github-tools/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; @@ -479,10 +480,21 @@ describe('Repository', function() { })); }); + it('should list pull request commits', function(done) { + const repo = github.getRepo('github-tools', 'github'); + repo.listPullRequestCommits(testPRNumber, assertSuccessful(done, function(err, commits) { + expect(commits).to.be.an.array(); + expect(commits).to.have.length(1); + expect(commits[0]).to.have.own('sha'); + + done(); + })); + }); + it('should get pull requests on repo', function(done) { const repo = github.getRepo('github-tools', 'github'); - repo.getPullRequest(153, assertSuccessful(done, function(err, pr) { + repo.getPullRequest(testPRNumber, assertSuccessful(done, function(err, pr) { expect(pr).to.have.own('title'); expect(pr).to.have.own('body'); expect(pr).to.have.own('url'); 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