This package has been deprecated

Author message:

octokit-create-pull-request has been renamed to octokit-plugin-create-pull-request

octokit-create-pull-request

1.5.0 • Public • Published

octokit-create-pull-request

Octokit plugin to create a pull request with multiple file changes

@latest Build Status Greenkeeper

Features

  • Retrieves the repository’s default branch unless base branch is set
  • Makes multiple file changes using a single commit
  • Creates a fork if the authenticated user does not have write access to the repository
  • See Todos for more cool feature ideas! Pull requests welcome!

Usage

Update or create two files with a single commit

const { Octokit } = require("@octokit/core");
const createPullRequest = require("octokit-create-pull-request");
 
const MyOctokit = Octokit.plugin(createPullRequest);
 
const TOKEN = "secret123"; // token needs "repo" scope
const octokit = new MyOctokit({
  auth: TOKEN,
});
 
// Returns a normal Octokit PR response
// See https://octokit.github.io/rest.js/#octokit-routes-pulls-create
octokit
  .createPullRequest({
    owner: "repo-name",
    repo: "repo-name",
    title: "pull request title",
    body: "pull request description",
    base: "master" /* optional: defaults to default branch */,
    head: "pull-request-branch-name",
    changes: {
      files: {
        "path/to/file1.txt": "Content for file1",
        "path/to/file2.png": {
          content: "_base64_encoded_content_",
          encoding: "base64",
        },
        "path/to/file3.txt": null, // deletes file if it exists
      },
      commit: "creating file1.txt, file2.png and deleting file3.txt",
    },
  })
  .then((pr) => console.log(pr.data.number));

You can create a personal access token with the repo scope at https://github.com/settings/tokens/new?scopes=repo

Todos

  • Editing files based on current content
    Addsupporttopassafunctionasfilecontent,thefunctionwillbecalledwiththecurrentfilecontent,ifpresent.
  • Multiple commits
    Splitupchangesamongmultipleedits

LICENSE

MIT

Package Sidebar

Install

npm i octokit-create-pull-request

Weekly Downloads

182

Version

1.5.0

License

MIT

Unpacked Size

380 kB

Total Files

23

Last publish

Collaborators

  • gr2m