Skip to content

v5.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 04 Jun 18:18
· 4 commits to main since this release
ac571dc

5.0.0 (2023-06-04)

Features

  • allow update function to trigger file deletion (#130) (ac571dc)

BREAKING CHANGES

  • The meaning of null has changed!

Previously the following snippet was causing a file deletion.

files: {
  "file/to/delete.txt": null
}

If you want to retain this behavior you must use the DELETE_FILE Symbol

import { createPullRequest, DELETE_FILE } from 'octokit-plugin-create-pull-request';

files: {
  "file/to/delete.txt": DELETE_FILE
}

If you want to trigger a file deletion from an update function, you can now do so by returning the deleteFile Symbol.

import { createPullRequest, DELETE_FILE } from 'octokit-plugin-create-pull-request';

files: {
  "file/to/delete.txt": ({ exists, encoding, content }) => {
    const fileContent = Buffer.from(content, encoding).toString("utf-8")

    if (fileContent.includes('abc')) {
      // trigger file deletion
      return DELETE_FILE
    }

    // do not alter file content
    return null;
  }
}