From 7c06287c128bf4b1bfe21a482b72c4b573b26f2c Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 14 Oct 2022 06:51:14 +0200
Subject: [PATCH] fix(composer): support bump with short range (#18332)

---
 lib/modules/versioning/composer/index.spec.ts | 3 ++-
 lib/modules/versioning/composer/index.ts      | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/modules/versioning/composer/index.spec.ts b/lib/modules/versioning/composer/index.spec.ts
index 56820f37fa..4df706a988 100644
--- a/lib/modules/versioning/composer/index.spec.ts
+++ b/lib/modules/versioning/composer/index.spec.ts
@@ -113,7 +113,8 @@ describe('modules/versioning/composer/index', () => {
     ${'~1.0'}                 | ${'pin'}             | ${'1.0'}          | ${'V1.1'}        | ${'V1.1'}
     ${'^1.0'}                 | ${'pin'}             | ${'1.0'}          | ${'V1.1'}        | ${'V1.1'}
     ${'v1.0'}                 | ${'replace'}         | ${'1.0'}          | ${'1.1'}         | ${'v1.1'}
-    ${'^1.0'}                 | ${'bump'}            | ${'1.0.0'}        | ${'1.0.7'}       | ${'^1.0'}
+    ${'^1.0'}                 | ${'bump'}            | ${'1.0.0'}        | ${'1.0.7'}       | ${'^1.0.7'}
+    ${'^9.4'}                 | ${'bump'}            | ${'9.4.3'}        | ${'9.4.8'}       | ${'^9.4.8'}
     ${'<2.7.14'}              | ${'bump'}            | ${'2.0.3'}        | ${'2.0.4'}       | ${'<2.7.14'}
     ${'^1.0.0'}               | ${'bump'}            | ${'1.0.0'}        | ${'1.3.5'}       | ${'^1.3.5'}
     ${'^1'}                   | ${'replace'}         | ${'1.0.0'}        | ${'1.3.5'}       | ${'^1'}
diff --git a/lib/modules/versioning/composer/index.ts b/lib/modules/versioning/composer/index.ts
index 56fe9d1f41..cad5fabfe8 100644
--- a/lib/modules/versioning/composer/index.ts
+++ b/lib/modules/versioning/composer/index.ts
@@ -204,8 +204,10 @@ function getNewValue({
     regEx(/^[~^]([0-9]*(?:\.[0-9]*)?)$/).test(currentValue)
   ) {
     const operator = currentValue.substring(0, 1);
-    // handle ~4.1 case
-    if ((currentMajor && toMajor > currentMajor) || !toMinor) {
+    if (rangeStrategy === 'bump') {
+      newValue = `${operator}${newVersion}`;
+    } else if ((currentMajor && toMajor > currentMajor) || !toMinor) {
+      // handle ~4.1 case
       newValue = `${operator}${toMajor}.0`;
     } else {
       newValue = `${operator}${toMajor}.${toMinor}`;
-- 
GitLab