3.0.0 • Published 11 years ago

pull-request v3.0.0

Weekly downloads
23
License
-
Repository
github
Last release
11 years ago

pull-request

All the tools you need to commit to GitHub repos via the API and create pull requests

Supports:

  • exists: check if a repository already exists so you don't try and fork again
  • fork: fork a repository so you get a copy to edit
  • branch: create a new branch in a repository to edit
  • commit: commit changes to files within a branch
  • pull: create a pull request to have a human merge those changes

Build Status Dependency Status NPM version

Installation

npm install pull-request

API

pr.exists(user, repo, options, callback)

Returns true if github.com/:user/:repo exists, and false if requesting that url returns an error.

pr.fork(user, repo, options, callback)

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.

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:

See github-basic and note that auth is required

pr.branch(user, repo, from, to, options, callback)

Creates a new branch in github.com/:user/:repo using from as the source branch and to as the new branch name.

pr.commit(user, repo, commit, options, callback)

Commits a set of changes to github.com/:user/:repo. It only supports updating text files.

commit:

An object with:

propertytypedefaultdescription
branchString'master'The branch to commit to
messageStringrequiredThe commit message
updatesArray<FileUpdate>requiredThe actual changes to make

FileUpdate:

An object with:

propertytypedefaultdescription
pathStringrequiredThe file path within the repo (e.g. test/index.js)
contentStringrequiredThe new content of the file
modeString'100644'The mode to commit the file with (you probably don't want to change this)
typeString'blob'The type of entry to create (you probably don't want to change this)

options:

See github-basic and note that auth is required

Additionally the force object defaults to false and will force push the change if set to true. You almost certainly don't want to do this.

pr.pull(from, to, message, options, callback)

Creates a pull request from from to to.

from:

An object with:

propertytypedefaultdescription
userStringrequiredThe source user
repoStringrequiredThe source repository
branchString'master'The source branch

to:

An object with:

propertytypedefaultdescription
userStringrequiredThe destination user
repoStringrequiredThe destination repository
branchString'master'The destination branch

message:

Either:

propertytypedefaultdescription
titleStringrequiredThe title of the pull request
bodyString''The body of the pull request

or:

propertytypedefaultdescription
issueNumberrequiredAn issue number to convert into a pull request

options:

See github-basic and note that auth is required

Promises

All APIs return promises if callback is ommitted.

License

MIT

3.0.0

11 years ago

2.0.0

11 years ago

1.0.4

11 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago