Skip to content

Commit

Permalink
GH-35943: [Dev] Ensure link issue works when PR body is empty (#36460)
Browse files Browse the repository at this point in the history
### 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: raulcd#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]>
  • Loading branch information
raulcd authored Jul 5, 2023
1 parent 20d5c31 commit 0df414e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/dev_pr/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
Expand Down

0 comments on commit 0df414e

Please sign in to comment.