From 8977ee483902c5f0bf62566c89e8ce4c1ed4a22d Mon Sep 17 00:00:00 2001 From: Ben Monro Date: Wed, 11 Apr 2018 15:44:57 -0700 Subject: [PATCH 1/3] added fork to org --- lib/Repository.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..b63fb79f 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -493,7 +493,19 @@ class Repository extends Requestable { fork(cb) { return this._request('POST', `/repos/${this.__fullname}/forks`, null, cb); } - + + /** + * Fork a repository to an organization + * @see https://developer.github.com/v3/repos/forks/#create-a-fork + * @param {String} org - organization where you'd like to create the fork. + * @param {Requestable.callback} cb - will receive the information about the newly created fork + * @return {Promise} - the promise for the http request + * + */ + forkToOrg(org, cb) { + return this._request('POST', `/repos/${this.__fullname}/forks?organization=${org}`, null, cb); + } + /** * List a repository's forks * @see https://developer.github.com/v3/repos/forks/#list-forks From 1e53f13d483d42858da83c811d6f36342f66aac3 Mon Sep 17 00:00:00 2001 From: Ben Monro Date: Wed, 11 Apr 2018 16:23:39 -0700 Subject: [PATCH 2/3] lint fix --- lib/Repository.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Repository.js b/lib/Repository.js index b63fb79f..6d6eb733 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -493,7 +493,7 @@ class Repository extends Requestable { fork(cb) { return this._request('POST', `/repos/${this.__fullname}/forks`, null, cb); } - + /** * Fork a repository to an organization * @see https://developer.github.com/v3/repos/forks/#create-a-fork @@ -505,7 +505,7 @@ class Repository extends Requestable { forkToOrg(org, cb) { return this._request('POST', `/repos/${this.__fullname}/forks?organization=${org}`, null, cb); } - + /** * List a repository's forks * @see https://developer.github.com/v3/repos/forks/#list-forks From d54b2ae6f37d58bf15c25b0f709416f1a5292471 Mon Sep 17 00:00:00 2001 From: Ben Monro Date: Wed, 11 Apr 2018 16:27:45 -0700 Subject: [PATCH 3/3] added test for forkToRepo --- test/repository.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/repository.spec.js b/test/repository.spec.js index ef5101cf..66f54df2 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -112,6 +112,10 @@ describe('Repository', function() { remoteRepo.fork(assertSuccessful(done)); }); + it('should fork repo to org', function(done) { + remoteRepo.forkToOrg('test-org', assertSuccessful(done)); + }); + it('should list forks of repo', function(done) { remoteRepo.listForks(assertSuccessful(done, function(err, forks) { expect(forks).to.be.an.array();