From bec847c3796bc663b591b71ebb5658273c9b9b47 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sat, 2 Mar 2019 10:45:10 +0100
Subject: [PATCH] feat: notify of possible groupings

Closes #3281
---
 lib/workers/repository/updates/branchify.js | 25 +++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/workers/repository/updates/branchify.js b/lib/workers/repository/updates/branchify.js
index ebbce8261c..fe71b48e67 100644
--- a/lib/workers/repository/updates/branchify.js
+++ b/lib/workers/repository/updates/branchify.js
@@ -96,6 +96,31 @@ function branchifyUpgrades(config, packageFiles) {
   const branchList = config.repoIsOnboarded
     ? branches.map(upgrade => upgrade.branchName)
     : config.branchList;
+  // istanbul ignore next
+  try {
+    // Here we check if there are updates from the same source repo
+    // that are not grouped into the same branch
+    const branchUpdates = {};
+    for (const branch of branches) {
+      const { sourceUrl, branchName, depName, toVersion } = branch;
+      const key = `${sourceUrl}|${toVersion}`;
+      branchUpdates[key] = branchUpdates[key] || {};
+      if (!branchUpdates[key][branchName]) {
+        branchUpdates[key][branchName] = depName;
+      }
+    }
+    for (const [k, v] of Object.entries(branchUpdates)) {
+      if (Object.keys(v).length > 1) {
+        const [sourceUrl, toVersion] = k.split('|');
+        logger.info(
+          { sourceUrl, toVersion, branches: v },
+          'Found sourceUrl with multiple branches that should probably be combined into a group'
+        );
+      }
+    }
+  } catch (err) {
+    logger.info({ err }, 'Error checking branch duplicates');
+  }
   return {
     errors: config.errors.concat(errors),
     warnings: config.warnings.concat(warnings),
-- 
GitLab