From 347d7dc51fe18da8d25d96954d0995a6f1f00b7e Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 21 Dec 2021 21:23:08 +0100
Subject: [PATCH] fix: move rebaseWhen=never check earlier (#13218)

---
 lib/workers/branch/index.ts                   | 30 +++++++++----------
 .../repository/dependency-dashboard.ts        |  8 -----
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts
index 4173209ffa..46cc828e91 100644
--- a/lib/workers/branch/index.ts
+++ b/lib/workers/branch/index.ts
@@ -338,13 +338,21 @@ export async function processBranch(
       }
     }
 
-    // istanbul ignore if
-    if (
+    const userRebaseRequested =
       dependencyDashboardCheck === 'rebase' ||
-      config.dependencyDashboardRebaseAllOpen
-    ) {
+      config.dependencyDashboardRebaseAllOpen ||
+      config.rebaseRequested;
+
+    if (userRebaseRequested) {
       logger.debug('Manual rebase requested via Dependency Dashboard');
       config.reuseExistingBranch = false;
+    } else if (branchExists && config.rebaseWhen === 'never') {
+      logger.debug('rebaseWhen=never so skipping branch update check');
+      return {
+        branchExists,
+        prNo: branchPr?.number,
+        result: BranchResult.NoWork,
+      };
     } else {
       config = { ...config, ...(await shouldReuseExistingBranch(config)) };
     }
@@ -430,16 +438,7 @@ export async function processBranch(
         });
       }
     }
-    const forcedManually =
-      !!dependencyDashboardCheck || config.rebaseRequested || !branchExists;
-    if (!forcedManually && config.rebaseWhen === 'never') {
-      logger.debug(`Skipping commit (rebaseWhen=never)`);
-      return {
-        branchExists,
-        prNo: branchPr?.number,
-        result: BranchResult.NoWork,
-      };
-    }
+    const forcedManually = userRebaseRequested || !branchExists;
     config.forceCommit = forcedManually || branchPr?.isConflicted;
     const commitSha = await commitFilesToBranch(config);
     // istanbul ignore if
@@ -466,8 +465,7 @@ export async function processBranch(
     // but do not break when there are artifact errors
     if (
       !config.artifactErrors?.length &&
-      !dependencyDashboardCheck &&
-      !config.rebaseRequested &&
+      !userRebaseRequested &&
       commitSha &&
       config.prCreation !== 'immediate'
     ) {
diff --git a/lib/workers/repository/dependency-dashboard.ts b/lib/workers/repository/dependency-dashboard.ts
index 7953327c40..7220cb3483 100644
--- a/lib/workers/repository/dependency-dashboard.ts
+++ b/lib/workers/repository/dependency-dashboard.ts
@@ -271,14 +271,6 @@ export async function ensureDependencyDashboard(
     issueBody += '## Other Branches\n\n';
     issueBody += `These updates are pending. To force PRs open, click the checkbox below.\n\n`;
     for (const branch of otherBranches) {
-      logger.info(
-        {
-          prBlockedBy: branch.prBlockedBy,
-          prNo: branch.prNo,
-          result: branch.result,
-        },
-        'Blocked PR'
-      );
       issueBody += getListItem(branch, 'other');
     }
     issueBody += '\n';
-- 
GitLab