Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added fork to org #503

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -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
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('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();
Expand Down