From 9606fe7fd0c02fef10e9bd06a59645b37786d551 Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:55:00 +0100 Subject: [PATCH] feat: add truncate warning to pull request body --- dist/index.js | 5 ++++- src/create-pull-request.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1c84bf4..cb568b3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -337,7 +337,10 @@ function createPullRequest(inputs) { // 65536 characters is the maximum allowed for the pull request body. if (inputs.body.length > 65536) { core.warning(`Pull request body is too long. Truncating to 65536 characters.`); - inputs.body = inputs.body.substring(0, 65536); + const truncateWarning = '...*[Pull request body truncated]*'; + inputs.body = + inputs.body.substring(0, 65536 - truncateWarning.length) + + truncateWarning; } // Get the repository path const repoPath = utils.getRepoPath(inputs.path); diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 12dddb8..1e7b8ba 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -52,7 +52,10 @@ export async function createPullRequest(inputs: Inputs): Promise { core.warning( `Pull request body is too long. Truncating to 65536 characters.` ) - inputs.body = inputs.body.substring(0, 65536) + const truncateWarning = '...*[Pull request body truncated]*' + inputs.body = + inputs.body.substring(0, 65536 - truncateWarning.length) + + truncateWarning } // Get the repository path