From 0df414e1c2d30132e363a3d559621bc4dc573a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 5 Jul 2023 11:32:27 +0200 Subject: [PATCH] GH-35943: [Dev] Ensure link issue works when PR body is empty (#36460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Rationale for this change Fix a bug when PR body is empty and Dev workflow fails. ### What changes are included in this PR? Ensure the link issue comment works in case of description being empty. ### Are these changes tested? I have tested it on my fork here: https://github.com/raulcd/arrow/pull/81 ### Are there any user-facing changes? No * Closes: #35943 Authored-by: Raúl Cumplido Signed-off-by: Raúl Cumplido --- .github/workflows/dev_pr/link.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev_pr/link.js b/.github/workflows/dev_pr/link.js index a3e0553c923a9..174bd3bae650a 100644 --- a/.github/workflows/dev_pr/link.js +++ b/.github/workflows/dev_pr/link.js @@ -84,14 +84,15 @@ async function commentGitHubURL(github, context, pullRequestNumber, issueID) { const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber); const message = "* Closes: #" + issueInfo.number if (issueInfo) { - if (context.payload.pull_request.body.includes(message)) { + const body = context.payload.pull_request.body || ""; + if (body.includes(message)) { return; } await github.rest.pulls.update({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pullRequestNumber, - body: (context.payload.pull_request.body || "") + "\n" + message + body: body + "\n" + message }); } }