From 71aebb0bd3b39afa7d4a0caaedab127c407e7eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:17:04 +0100 Subject: [PATCH 1/6] Add listCollaborators API --- src/github.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/github.js b/src/github.js index cb6546a5..c36b78c4 100644 --- a/src/github.js +++ b/src/github.js @@ -458,6 +458,12 @@ _request('GET', repoPath + '/pulls/' + number, null, cb); }; + // List all collaborators of a repository + // ------- + this.listCollaborators = function(cb) { + _request('GET', repoPath + "/collaborators", null, cb); + }; + // Retrieve the changes made between base and head // ------- From 8a4906a3fb00882e4c53cad5b710a818533cf669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:18:47 +0100 Subject: [PATCH 2/6] Add Issue events API --- src/github.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/github.js b/src/github.js index c36b78c4..0e959b24 100644 --- a/src/github.js +++ b/src/github.js @@ -1030,6 +1030,17 @@ _requestAllPages(path + '?' + query.join('&'), cb); }; + this.events = function(options, cb) { + var query = []; + + for (var key in options) { + if (options.hasOwnProperty(key)) { + query.push(encodeURIComponent(key) + "=" + encodeURIComponent(options[key])); + } + } + _requestAllPages(path + '/events' + '?' + query.join("&"), cb); + }; + this.comment = function (issue, comment, cb) { _request('POST', issue.comments_url, { body: comment From 40c1ca670f950f5fa007f397178e2ee3a4bf6a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:18:55 +0100 Subject: [PATCH 3/6] Add Issue comments API --- src/github.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/github.js b/src/github.js index 0e959b24..009af105 100644 --- a/src/github.js +++ b/src/github.js @@ -1041,6 +1041,17 @@ _requestAllPages(path + '/events' + '?' + query.join("&"), cb); }; + this.comments = function(options, cb) { + var query = []; + + for (var key in options) { + if (options.hasOwnProperty(key)) { + query.push(encodeURIComponent(key) + "=" + encodeURIComponent(options[key])); + } + } + _requestAllPages(path + '/comments' + '?' + query.join("&"), cb); + }; + this.comment = function (issue, comment, cb) { _request('POST', issue.comments_url, { body: comment From 2b13784a985d51da0755e664480b1ce13d9a5c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:21:31 +0100 Subject: [PATCH 4/6] Add test for listCollaborators --- test/test.repo.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test.repo.js b/test/test.repo.js index bb405cdc..c5c99804 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -425,6 +425,18 @@ describe('Creating new Github.Repository', function() { }); }); + it('should list collaborators of repo', function(done) { + var repo = github.getRepo('michael', 'github'); + + repo.listCollaborators(function(err, collabs, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + + // @TODO write better assertion + done(); + }); + }); + it('should delete a file on the repo', function(done) { repo.write('master', 'REMOVE-TEST.md', 'THIS IS A TEST', 'Remove test', function(err) { should.not.exist(err); From 5503b9d05a58c3bb01e50a0c3d658dc2c7635cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:22:56 +0100 Subject: [PATCH 5/6] Add test for Issue events API --- test/test.issue.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test.issue.js b/test/test.issue.js index a4c6c1a9..fc92ba88 100644 --- a/test/test.issue.js +++ b/test/test.issue.js @@ -44,6 +44,16 @@ describe('Github.Issue', function() { }); }); + it('should list events', function(done) { + issues.events(null, function(err, events, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + events.should.have.length.above(0); + + done(); + }); + }); + it('should post issue comment', function(done) { issues.comment(issue, 'Comment test', function(err, res, xhr) { should.not.exist(err); From b5e0131e7c72a9020672f308b42863cd2761fcf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 24 Feb 2016 09:25:33 +0100 Subject: [PATCH 6/6] Add test for Issue comments API --- test/test.issue.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test.issue.js b/test/test.issue.js index fc92ba88..4f1d2ad3 100644 --- a/test/test.issue.js +++ b/test/test.issue.js @@ -54,6 +54,16 @@ describe('Github.Issue', function() { }); }); + it('should list comments', function(done) { + issues.comments(null, function(err, comments, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + comments.should.have.length.above(0); + + done(); + }); + }); + it('should post issue comment', function(done) { issues.comment(issue, 'Comment test', function(err, res, xhr) { should.not.exist(err);