Skip to content

Commit

Permalink
feat: Adding repository.compare() (#30)
Browse files Browse the repository at this point in the history
* tests for repository.compare()
* forgot to expose new methods!
  • Loading branch information
dcolens authored and fengmk2 committed Jan 10, 2017
1 parent 7b1fff8 commit 9d5c1d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ var properties = {
'getTags',
'getCommits',
'getTree',
'getBlob'
'getBlob',
'archive',
'compare'
],
issues: [
'listNotes',
Expand Down
14 changes: 14 additions & 0 deletions lib/resources/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,18 @@ Repository.prototype.archive = function (params, callback) {
this.client.request('get', this.path, params, callback);
};

/**
* Compare branches, tags or commits.
*
* @param {Object} params
* - {String} id (required) The ID of a project
* - {String} from (required) - the commit SHA or branch name
* - {String} to (required) - the commit SHA or branch name
* @param {Function} callback
*/
Repository.prototype.compare = function (params, callback) {
params.type = 'compare';
this.client.request('get', this.path, params, callback);
};


13 changes: 13 additions & 0 deletions test/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,17 @@ describe.skip('repository.test.js', function () {
});
});
});

describe('client.repository.compare()', function () {
it('should return diffs', function (done) {
client.repository.compare({id: 55045, to: 'master', from: '946579807281bd26b75b91986c78f15ad0bd40f7'}, function (err, diffs) {
should.not.exists(err);
should.exists(diffs);
diffs.should.have.keys('commit', 'commits', 'diffs', 'compare_timeout', 'compare_same_ref');
diffs.commits.should.be.instanceof(Array);
diffs.diffs.should.be.instanceof(Array);
done();
});
});
});
});

0 comments on commit 9d5c1d0

Please sign in to comment.