diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..6d6eb733 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -494,6 +494,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 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();