gr2m / octokit-plugin-create-pull-request

Octokit plugin to create a pull request with multiple file changes
MIT License
104 stars 28 forks source link

Update file based on current content: handle 404 #51

Closed gr2m closed 4 years ago

gr2m commented 4 years ago

The current README example's fails if path/to/file4.txt does not yet exist:

// Returns a normal Octokit PR response
// See https://octokit.github.io/rest.js/#octokit-routes-pulls-create
octokit
  .createPullRequest({
    owner: "user-or-org-login",
    repo: "repo-name",
    title: "pull request title",
    body: "pull request description",
    head: "pull-request-branch-name",
    changes: [
      {
        /* optional: if `files` is not passed, an empty commit is created instead */
        files: {
          "path/to/file4.txt": ({ encoding, content }) => {
            return Buffer.from(content, encoding)
              .toString("utf-8")
              .toUpperCase();
          },
        },
        commit:
          "update file4.txt",
      },
    ],
  })

add a new { exists } key to the current argument that is always set to true or false. When set to false, no other keys are set

github-actions[bot] commented 4 years ago

:tada: This issue has been resolved in version 3.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: