This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 0df414e1c2 GH-35943: [Dev] Ensure link issue works when PR body is 
empty (#36460)
0df414e1c2 is described below

commit 0df414e1c2d30132e363a3d559621bc4dc573a9b
Author: Raúl Cumplido <[email protected]>
AuthorDate: Wed Jul 5 11:32:27 2023 +0200

    GH-35943: [Dev] Ensure link issue works when PR body is empty (#36460)
    
    ### 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 <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 .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 a3e0553c92..174bd3bae6 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
     });
   }
 }

Reply via email to