Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions 17 lib/Repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions 18 test/repository.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.