Skip to content
Closed
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ Get contributors list with additions, deletions, and commit counts.
repo.contributors(function(err, data) {});
```

Get collaborators list.

```js
repo.collaborators(function(err, data) {});
```

Check if user is a collaborator on the repository.

```js
repo.isCollaborator(username, function(err) {});
```

Check if a repository is starred.

```js
Expand Down
4 changes: 2 additions & 2 deletions dist/github.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/github.bundle.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/github.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/github.min.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,20 @@
});
};

// Show repository collaborators
// -------

this.collaborators = function (cb) {
_request('GET', repoPath + '/collaborators', null, cb);
};

// Check whether user is a collaborator on the repository
// -------

this.isCollaborator = function (username, cb) {
_request('GET', repoPath + '/collaborators/' + username, null, cb);
};

// Get contents
// --------

Expand Down
25 changes: 25 additions & 0 deletions test/test.repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,31 @@ describe('Github.Repository', function() {
});
});

it('should show repo collaborators', function(done) {
repo.collaborators(function(err, res, xhr) {
should.not.exist(err);
xhr.should.be.instanceof(XMLHttpRequest);
res.should.be.instanceof(Array);
res.should.have.length.above(1);
should.exist(res[0].login);
should.exist(res[0].id);
should.exist(res[0].permissions);

done();
});
});

it('should test whether user is collaborator', function(done) {
repo.isCollaborator('michael', function(err, res, xhr) {
should.not.exist(err);
should.not.exist(res);
xhr.should.be.instanceof(XMLHttpRequest);
xhr.status.should.equal(204);

done();
});
});

// @TODO repo.branch, repo.pull

it('should list repo branches', function(done) {
Expand Down