Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding repository.compare() #30

Merged
merged 3 commits into from
Jan 10, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
});
});
});
});