pull-request
Advanced tools
Comparing version 1.0.4 to 2.0.0
12
index.js
@@ -54,11 +54,15 @@ 'use strict' | ||
exports.fork = fork | ||
function fork(from, to, repo, options, callback) { | ||
function fork(user, repo, options, callback) { | ||
options = options || {} | ||
//N.B. `org` is listed as `organization` in the spec, but that doesn't currently work :( | ||
return github.json('post', '/repos/:owner/:repo/forks', {owner: from, repo: repo, org: to}, options) | ||
var query = {owner: user, repo: repo} | ||
if (options.organization) { | ||
query.organization = options.organization | ||
} | ||
return github.json('post', '/repos/:owner/:repo/forks', query, options) | ||
.then(function (res) { | ||
return poll(function () { | ||
return exists(to, repo, options) | ||
return exists(res.body.owner.login, repo, options) | ||
}, {timeout: options.timeout || '5 minutes', delay: function (attempt) { return (attempt * 5) + 'seconds' }}) | ||
.then(function () { return res }) | ||
.then(function () { return res.body }) | ||
}).nodeify(callback) | ||
@@ -65,0 +69,0 @@ } |
{ | ||
"name": "pull-request", | ||
"version": "1.0.4", | ||
"version": "2.0.0", | ||
"description": "Fork, Commit and Pull Request via the GitHub API", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -27,5 +27,5 @@ # pull-request | ||
### pr.fork(from, to, repo, options, callback) | ||
### pr.fork(user, repo, options, callback) | ||
Forks the repo `github.com/:from/:repo` to `github.com/:to/:repo` and waits until the fork operation completes. | ||
Forks the repo `github.com/:user/:repo` to the authenticated user and waits until the fork operation completes. To fork to an organization, just add an `organization` string to the `options` object. | ||
@@ -32,0 +32,0 @@ **N.B.** forking will currently appear successful even if the target repo already exists. This functionality should not be relied upon and is subject to change without necessarily updating the MAJOR version. |
@@ -31,6 +31,6 @@ var assert = require('assert') | ||
var branch = (new Date()).toISOString().replace(/[^0-9a-zA-Z]+/g, '') | ||
describe('fork(from, to, repo, options)', function () { | ||
it('forks `repo` from `from` to `to`', function (done) { | ||
describe('fork(user, repo, options)', function () { | ||
it('forks `user/repo` to the current user', function (done) { | ||
this.timeout(60000) | ||
pr.fork('ForbesLindesay', 'github-basic-js-test', 'pull-request-test', options, function (err, res) { | ||
pr.fork('ForbesLindesay', 'pull-request-test', options, function (err, res) { | ||
if (err) return done(err) | ||
@@ -37,0 +37,0 @@ pr.exists('github-basic-js-test', 'pull-request-test', function (err, res) { |
14524
211