pull-request
Advanced tools
Comparing version 1.0.2 to 1.0.3
25
index.js
@@ -56,3 +56,4 @@ 'use strict' | ||
options = options || {} | ||
return github.json('post', '/repos/:owner/:repo/forks', {owner: from, repo: repo, organization: to}, 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) | ||
.then(function (res) { | ||
@@ -68,6 +69,12 @@ return poll(function () { | ||
function branch(user, repo, from, to, options, callback) { | ||
github.json('get', '/repos/:owner/:repo/git/refs/:ref', {owner: user, repo: repo, ref: 'heads/' + from}) | ||
return github.json('get', '/repos/:owner/:repo/git/refs/:ref', {owner: user, repo: repo, ref: 'heads/' + from}, options) | ||
.then(function (res) { | ||
return github.json('post', '/repos/:owner/:repo/git/refs', {owner: user, repo: repo, ref: 'refs/heads/' + to, sha: res.object.sha}) | ||
return github.json('post', '/repos/:owner/:repo/git/refs', { | ||
owner: user, | ||
repo: repo, | ||
ref: 'refs/heads/' + to, | ||
sha: res.body.object.sha | ||
}, options) | ||
}) | ||
.nodeify(callback) | ||
} | ||
@@ -82,3 +89,3 @@ | ||
Promise.from(null).then(function () { | ||
return Promise.from(null).then(function () { | ||
@@ -100,12 +107,12 @@ //check for correct input | ||
}).then(function (res) { | ||
shaLatestCommit = res.object.sha | ||
shaLatestCommit = res.body.object.sha | ||
return github.json('get', '/repos/:owner/:repo/git/commits/:sha', {owner: user, repo: repo, sha: shaLatestCommit}, options) | ||
}).then(function (res) { | ||
shaBaseTree = res.tree.sha | ||
shaBaseTree = res.body.tree.sha | ||
return github('post', '/repos/:owner/:repo/git/trees', {owner: user, repo: repo, tree: updates, base_tree: shaBaseTree}, options) | ||
}).then(function (res) { | ||
shaNewTree = res.sha | ||
shaNewTree = res.body.sha | ||
return github.json('post', '/repos/:owner/:repo/git/commits', {owner: user, repo: repo, message: message, tree: shaNewTree, parents: [shaLatestCommit]}, options) | ||
}).then(function (res) { | ||
shaNewCommit = res.sha | ||
shaNewCommit = res.body.sha | ||
return github.json('patch', '/repos/:owner/:repo/git/refs/:ref', {owner: user, repo: repo, ref: 'heads/' + branch, sha: shaNewCommit, force: options.force || false}) | ||
@@ -129,3 +136,3 @@ }).nodeify(callback) | ||
} | ||
return github.json('post', '/repos/:owner/:repo/pulls', query, options) | ||
return github.json('post', '/repos/:owner/:repo/pulls', query, options).nodeify(callback) | ||
} |
{ | ||
"name": "pull-request", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Fork, Commit and Pull Request via the GitHub API", | ||
"keywords": [], | ||
"dependencies": { | ||
"github-basic": "~1.0.0", | ||
"github-basic": "~1.0.2", | ||
"ms": "~0.6.1", | ||
@@ -9,0 +9,0 @@ "promise": "~3.2.0" |
@@ -31,2 +31,4 @@ # pull-request | ||
**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. | ||
**options:** | ||
@@ -33,0 +35,0 @@ |
var assert = require('assert') | ||
var github = require('github-basic') | ||
var pr = require('../') | ||
@@ -19,2 +20,43 @@ | ||
}) | ||
}) | ||
// github-basic-js-test | ||
var options = { | ||
auth: { | ||
type: 'oauth', | ||
token: '90993e4e47b0fdd1f51f4c67b17368c62a3d6097' | ||
} | ||
} | ||
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) { | ||
this.timeout(60000) | ||
pr.fork('ForbesLindesay', 'github-basic-js-test', 'pull-request-test', options, function (err, res) { | ||
if (err) return done(err) | ||
pr.exists('github-basic-js-test', 'pull-request-test', function (err, res) { | ||
if (err) return done(err) | ||
assert(res === true) | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
describe('branch(user, repo, form, to, options)', function () { | ||
it('creates a new branch `to` in `user/repo` based on `from`', function (done) { | ||
this.timeout(10000) | ||
pr.branch('github-basic-js-test', 'pull-request-test', 'master', branch, options, function (err, res) { | ||
if (err) return done(err) | ||
github.buffer('head', '/repos/github-basic-js-test/pull-request-test/git/refs/heads/:branch', {branch: branch}, options, done) | ||
}) | ||
}) | ||
}) | ||
describe('commit', function () { | ||
}) | ||
describe('pull', function () { | ||
}) |
13080
173
122
Updatedgithub-basic@~1.0.2