From 0f7e0dde99a4555f7396ca1333e5852d7de87158 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 27 May 2020 07:13:54 +0200 Subject: [PATCH] fix: remove PR has been edited comments --- lib/platform/github/index.ts | 3 ++- lib/workers/branch/index.ts | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 8b94795b15..2639056099 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -1579,7 +1579,7 @@ export async function ensureCommentRemoval({ topic, content, }: EnsureCommentRemovalConfig): Promise<void> { - logger.debug( + logger.trace( `Ensuring comment "${topic || content}" in #${issueNo} is removed` ); const comments = await getComments(issueNo); @@ -1598,6 +1598,7 @@ export async function ensureCommentRemoval({ try { if (commentId) { + logger.debug({ issueNo }, 'Removing comment'); await deleteComment(commentId); } } catch (err) /* istanbul ignore next */ { diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index c92e6f50ba..a1635edc19 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -160,12 +160,13 @@ export async function processBranch( ); throw new Error(REPOSITORY_CHANGED); } + const topic = 'PR has been edited'; if ( branchPr.isModified || (branchPr.targetBranch && branchPr.targetBranch !== branchConfig.baseBranch) ) { - const topic = 'PR has been edited'; + logger.debug({ prNo: branchPr.number }, 'PR has been edited'); if (masterIssueCheck || config.rebaseRequested) { if (config.dryRun) { logger.info( @@ -198,6 +199,11 @@ export async function processBranch( } return 'pr-edited'; } + } else { + await platform.ensureCommentRemoval({ + number: branchPr.number, + topic, + }); } } } -- GitLab