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

Add options to the listReleases and listTags function #485

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions lib/Repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ class Repository extends Requestable {
/**
* List the tags on a repository
* @see https://developer.github.com/v3/repos/#list-tags
* @param {Object} options - pagination for the list
* @param {Requestable.callback} [cb] - will receive the tag data
* @return {Promise} - the promise for the http request
*/
listTags(cb) {
return this._request('GET', `/repos/${this.__fullname}/tags`, null, cb);
listTags(options, cb = options) {
return this._request('GET', `/repos/${this.__fullname}/tags`, options !== 'function' && options, cb);
}

/**
Expand Down Expand Up @@ -793,11 +794,12 @@ class Repository extends Requestable {
/**
* Get information about all releases
* @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
* @param {Object} options - pagination for the list
* @param {Requestable.callback} cb - will receive the release information
* @return {Promise} - the promise for the http request
*/
listReleases(cb) {
return this._request('GET', `/repos/${this.__fullname}/releases`, null, cb);
listReleases(options, cb = options) {
return this._request('GET', `/repos/${this.__fullname}/releases`, options !== 'function' && options, cb);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Markdown', function() {
};
markdown.render(options)
.then(function({data: html}) {
expect(html).to.be('<p>Hello world <a href="https://github.com/github/linguist/issues/1" class="issue-link js-issue-link" data-url="https://github.com/github/linguist/issues/1" data-id="1012654" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">github/linguist#1</a> <strong>cool</strong>, and <a href="https://github.com/gollum/gollum/issues/1" class="issue-link js-issue-link" data-url="https://github.com/gollum/gollum/issues/1" data-id="183433" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#1</a>!</p>'); // eslint-disable-line
expect(html).to.be('<p>Hello world <a href="https://github.com/github/linguist/issues/1" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="1012654" data-permission-text="Issue title is private" data-url="https://github.com/github/linguist/issues/1">github/linguist#1</a> <strong>cool</strong>, and <a href="https://github.com/gollum/gollum/issues/1" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="183433" data-permission-text="Issue title is private" data-url="https://github.com/gollum/gollum/issues/1">#1</a>!</p>'); // eslint-disable-line
done();
}).catch(done);
});
Expand Down
14 changes: 14 additions & 0 deletions test/repository.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ describe('Repository', function() {
});

it('should list tags on repo', function(done) {
const options = {
per_page: 30 //eslint-disable-line
};

remoteRepo.listTags(options, assertSuccessful(done));
remoteRepo.listTags(assertSuccessful(done));
});

Expand Down Expand Up @@ -628,6 +633,15 @@ describe('Repository', function() {
});

it('should read all releases', function(done) {
const options = {
per_page: 30 //eslint-disable-line
};

remoteRepo.listReleases(options, assertSuccessful(done, function(err, releases) {
expect(releases).to.be.an.array();
done();
}));

remoteRepo.listReleases(assertSuccessful(done, function(err, releases) {
expect(releases).to.be.an.array();
done();
Expand Down