Skip to content

Commit 849e058

Browse files
timwisAurelioDeRosa
authored andcommitted
Added repo.collaborators and repo.isCollaborator
Closes github-toolsgh-304
1 parent ade2bf6 commit 849e058

File tree

7 files changed

+55
-5
lines changed

7 files changed

+55
-5
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ Get contributors list with additions, deletions, and commit counts.
246246
repo.contributors(function(err, data) {});
247247
```
248248

249+
Get collaborators list.
250+
251+
```js
252+
repo.collaborators(function(err, data) {});
253+
```
254+
255+
Check if user is a collaborator on the repository.
256+
257+
```js
258+
repo.isCollaborator(username, function(err) {});
259+
```
260+
249261
Check if a repository is starred.
250262

251263
```js

dist/github.bundle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.bundle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,20 @@
685685
});
686686
};
687687

688+
// Show repository collaborators
689+
// -------
690+
691+
this.collaborators = function (cb) {
692+
_request('GET', repoPath + '/collaborators', null, cb);
693+
};
694+
695+
// Check whether user is a collaborator on the repository
696+
// -------
697+
698+
this.isCollaborator = function (username, cb) {
699+
_request('GET', repoPath + '/collaborators/' + username, null, cb);
700+
};
701+
688702
// Get contents
689703
// --------
690704

test/test.repo.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,30 @@ describe('Creating new Github.Repository', function() {
276276
});
277277
});
278278

279+
it('should show repo collaborators', function(done) {
280+
repo.collaborators(function(err, res, xhr) {
281+
should.not.exist(err);
282+
xhr.should.be.instanceof(XMLHttpRequest);
283+
res.should.be.instanceof(Array);
284+
res.should.have.length(1);
285+
res[0].login.should.equal(testUser.USERNAME);
286+
should.exist(res[0].id);
287+
should.exist(res[0].permissions);
288+
289+
done();
290+
});
291+
});
292+
293+
it('should test whether user is collaborator', function(done) {
294+
repo.isCollaborator(testUser.USERNAME, function(err, res, xhr) {
295+
should.not.exist(err);
296+
xhr.should.be.instanceof(XMLHttpRequest);
297+
xhr.status.should.equal(204);
298+
299+
done();
300+
});
301+
});
302+
279303
it('should write to repo', function(done) {
280304
repo.write('master', 'TEST.md', 'THIS IS A TEST', 'Creating test', function(err) {
281305
should.not.exist(err);

0 commit comments

Comments
 (0)