Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/Repository.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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