Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update file based on current content: handle 404 #51

Closed
gr2m opened this issue Jun 29, 2020 · 1 comment · Fixed by #52
Closed

Update file based on current content: handle 404 #51

gr2m opened this issue Jun 29, 2020 · 1 comment · Fixed by #52
Assignees
Labels

Comments

@gr2m
Copy link
Owner

gr2m commented Jun 29, 2020

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

@gr2m gr2m self-assigned this Jun 29, 2020
gr2m added a commit that referenced this issue Jun 29, 2020
@gr2m gr2m closed this as completed in #52 Jun 29, 2020
gr2m added a commit that referenced this issue Jun 29, 2020
* docs(README): `exists` key for update functions

* docs(CONTRIBUTING): record error requests

* test: `exists` key for update functions

* feat: `exists` key for update functions

fixes #51

* test: empty update

* fix: skip creating tree if there are no changes
@github-actions
Copy link

🎉 This issue has been resolved in version 3.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant