From 1b40c31e130ff14022ed5bf02a15f049f636ba3b Mon Sep 17 00:00:00 2001 From: harry Date: Fri, 25 Apr 2025 15:26:46 +0100 Subject: [PATCH] guide comment remover stops stealing my edits (#90820) ## About The Pull Request the guide comment remover no longer steals your edits made between the job being created and being run ## Why It's Good For The Game evil techno goblins stealing my edits fixes #89970 ## Changelog no player facing changes --------- Co-authored-by: harryob <55142896+harryob@users.noreply.github.com> --- tools/pull_request_hooks/removeGuideComments.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/pull_request_hooks/removeGuideComments.js b/tools/pull_request_hooks/removeGuideComments.js index c7cdcd1ca67..164470d84c9 100644 --- a/tools/pull_request_hooks/removeGuideComments.js +++ b/tools/pull_request_hooks/removeGuideComments.js @@ -16,13 +16,15 @@ function escapeRegex(string) { } export async function removeGuideComments({ github, context }) { - let newBody = context.payload.pull_request.body; + const originalBody = (await github.rest.pulls.get(context.issue)).body; - if (!newBody) { + if (!originalBody) { console.log("PR body is empty, skipping..."); return; } + let newBody = originalBody; + for (const comment of comments) { newBody = newBody.replace( new RegExp(`^\\s*${escapeRegex(comment)}\\s*`, "gm"), @@ -30,7 +32,7 @@ export async function removeGuideComments({ github, context }) { ); } - if (newBody !== context.payload.pull_request.body) { + if (newBody !== originalBody) { await github.rest.pulls.update({ pull_number: context.payload.pull_request.number, repo: context.repo.repo,