Skip to content

Commit

Permalink
Merge pull request #558 from WJXHenry/fork-to-org
Browse files Browse the repository at this point in the history
Fork to organization
  • Loading branch information
j-rewerts committed May 3, 2019
2 parents 09384e3 + 5781a87 commit 935783f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Repository.js
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/repository.spec.js
Expand Up @@ -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();
Expand Down

0 comments on commit 935783f

Please sign in to comment.