From 0f456d0615ed8b55c169c44c2f01a84c998499ed Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 12 Feb 2021 23:41:20 +0100
Subject: [PATCH] refactor: getBucket

---
 .../repository/process/lookup/index.ts        | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts
index 7216f59bea..fdd4a0fc78 100644
--- a/lib/workers/repository/process/lookup/index.ts
+++ b/lib/workers/repository/process/lookup/index.ts
@@ -112,24 +112,33 @@ function getFromVersion(
   return version.getSatisfyingVersion(useVersions, currentValue);
 }
 
-function getBucket(config: LookupUpdateConfig, update: LookupUpdate): string {
+function getBucket(
+  config: LookupUpdateConfig,
+  fromVersion: string,
+  toVersion: string,
+  versioning: allVersioning.VersioningApi
+): string {
   const {
     separateMajorMinor,
     separateMultipleMajor,
     separateMinorPatch,
   } = config;
-  const { updateType, newMajor } = update;
   if (!separateMajorMinor) {
     return 'latest';
   }
-  if (updateType === 'major') {
+  const fromMajor = versioning.getMajor(fromVersion);
+  const toMajor = versioning.getMajor(toVersion);
+  if (fromMajor !== toMajor) {
     if (separateMultipleMajor) {
-      return `major-${newMajor}`;
+      return `major-${toMajor}`;
     }
     return 'major';
   }
   if (separateMinorPatch) {
-    return updateType;
+    if (versioning.getMinor(fromVersion) === versioning.getMinor(toVersion)) {
+      return 'patch';
+    }
+    return 'minor';
   }
   return 'non-major';
 }
@@ -341,7 +350,7 @@ export async function lookupUpdates(
       update.updateType =
         update.updateType || getType(config, fromVersion, toVersion);
 
-      const bucket = getBucket(config, update);
+      const bucket = getBucket(config, fromVersion, toVersion, versioning);
       if (buckets[bucket]) {
         buckets[bucket].push(update);
       } else {
-- 
GitLab