Skip to content

Commit

Permalink
GH-14790: [Dev] Avoid extra comment with Closes issue id on PRs (#35811)
Browse files Browse the repository at this point in the history
### Rationale for this change

We are duplicating the Closes issue_id comment on PRs adding it to both the PR body and a comment. There was some discussion to remove it from the comment.

### What changes are included in this PR?

Remove adding extra comment to PR and check whether `Closes XXX` was already added on the body instead of checking comment.

### Are these changes tested?

Yes, I have tested on my fork, see this PR: raulcd#79

### Are there any user-facing changes?

No
* Closes: #14790

Lead-authored-by: Raúl Cumplido <raulcumplido@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
  • Loading branch information
raulcd and kou authored May 30, 2023
1 parent 1951a1a commit 431785f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/dev_pr/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,16 @@ async function commentGitHubURL(github, context, pullRequestNumber, issueID) {
// Make the call to ensure issue exists before adding comment
const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber);
const message = "* Closes: #" + issueInfo.number
if (await haveComment(github, context, pullRequestNumber, message)) {
return;
}
if (issueInfo){
if (issueInfo) {
if (context.payload.pull_request.body.includes(message)) {
return;
}
await github.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequestNumber,
body: (context.payload.pull_request.body || "") + "\n" + message
});
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: message
});
}
}

Expand Down

0 comments on commit 431785f

Please sign in to comment.