From e4ff7edee9290a60bcace28e272065ec22027d2f Mon Sep 17 00:00:00 2001 From: RahulGautamSingh <rahultesnik@gmail.com> Date: Sun, 16 Oct 2022 11:26:03 +0530 Subject: [PATCH] refactor: move stop-updating-label logic (#18350) --- lib/workers/repository/update/branch/index.ts | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index 88d559f24d..ac2e342096 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -176,6 +176,26 @@ export async function processBranch( }; } if (branchExists) { + // check if branch is labelled to stop + config.stopUpdating = branchPr?.labels?.includes( + config.stopUpdatingLabel! + ); + + const prRebaseChecked = !!branchPr?.bodyStruct?.rebaseRequested; + + if (branchExists && !dependencyDashboardCheck && config.stopUpdating) { + if (!prRebaseChecked) { + logger.info( + 'Branch updating is skipped because stopUpdatingLabel is present in config' + ); + return { + branchExists: true, + prNo: branchPr?.number, + result: BranchResult.NoWork, + }; + } + } + logger.debug('Checking if PR has been edited'); const branchIsModified = await isBranchModified(config.branchName); if (branchPr) { @@ -482,25 +502,6 @@ export async function processBranch( (await isBranchConflicted(config.baseBranch, config.branchName)); config.forceCommit = forcedManually || config.isConflicted; - config.stopUpdating = branchPr?.labels?.includes( - config.stopUpdatingLabel! - ); - - const prRebaseChecked = !!branchPr?.bodyStruct?.rebaseRequested; - - if (branchExists && !dependencyDashboardCheck && config.stopUpdating) { - if (!prRebaseChecked) { - logger.info( - 'Branch updating is skipped because stopUpdatingLabel is present in config' - ); - return { - branchExists: true, - prNo: branchPr?.number, - result: BranchResult.NoWork, - }; - } - } - // compile commit message with body, which maybe needs changelogs if (config.commitBody) { if ( -- GitLab