From 5781a8758e6730811cc58c037faed4593a3b3b8b Mon Sep 17 00:00:00 2001 From: WJXHenry Date: Thu, 2 May 2019 14:32:26 -0600 Subject: [PATCH] Switched 'test-org' to 'github-api-tests' --- lib/Repository.js | 12 ++++++++++++ test/repository.spec.js | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lib/Repository.js b/lib/Repository.js index f59cf0d0..e796e1bf 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -504,6 +504,18 @@ class Repository extends Requestable { 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 diff --git a/test/repository.spec.js b/test/repository.spec.js index 62bb3ba6..5498cb24 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(testUser.ORGANIZATION, assertSuccessful(done)); + }); + it('should list forks of repo', function(done) { remoteRepo.listForks(assertSuccessful(done, function(err, forks) { expect(forks).to.be.an.array();