pull-request

Fork, Commit and Pull Request via the GitHub API

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

npm install pull-request

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

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

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

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.

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

All APIs return promises if callback is ommitted.

MIT