From 82a1f32b9a815e99712cefb39bc6d4f9b745eb98 Mon Sep 17 00:00:00 2001 From: Gabriel-Ladzaretti <97394622+Gabriel-Ladzaretti@users.noreply.github.com> Date: Wed, 10 Aug 2022 18:36:36 +0300 Subject: [PATCH] fix(repo/update): dry run - skip PR update when branch is modified (#17114) Co-authored-by: Rhys Arkins <rhys@arkins.net> --- .../repository/update/branch/index.spec.ts | 4 ++++ lib/workers/repository/update/branch/index.ts | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index 9652a2439c..a541728960 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -940,6 +940,10 @@ describe('workers/repository/update/branch/index', () => { prNo: undefined, result: 'pr-edited', }); + expect(logger.info).toHaveBeenCalledWith( + `DRY-RUN: Would update existing PR to indicate that rebasing is not possible` + ); + expect(platform.updatePr).toHaveBeenCalledTimes(0); }); it('branch pr no schedule lockfile (dry run)', async () => { diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index d2d2bfe6ce..53f1ef2cf9 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -198,15 +198,21 @@ export async function processBranch( }); const newBodyHash = hashBody(newBody); if (newBodyHash !== branchPr.bodyStruct?.hash) { - logger.debug( - 'Updating existing PR to indicate that rebasing is not possible' - ); - await platform.updatePr({ - number: branchPr.number, - prTitle: branchPr.title, - prBody: newBody, - platformOptions: getPlatformPrOptions(config), - }); + if (GlobalConfig.get('dryRun')) { + logger.info( + `DRY-RUN: Would update existing PR to indicate that rebasing is not possible` + ); + } else { + logger.debug( + 'Updating existing PR to indicate that rebasing is not possible' + ); + await platform.updatePr({ + number: branchPr.number, + prTitle: branchPr.title, + prBody: newBody, + platformOptions: getPlatformPrOptions(config), + }); + } } return { branchExists, -- GitLab