From 4f4390a1554cf740850a8abe644bf7c06b5caac6 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 14 Dec 2024 10:51:55 +0100 Subject: [PATCH 1/3] feat: sharedVariableName --- lib/config/types.ts | 1 + lib/modules/manager/cocoapods/extract.ts | 16 ++-- lib/modules/manager/cocoapods/types.ts | 2 +- .../gradle/__snapshots__/parser.spec.ts.snap | 2 +- lib/modules/manager/gradle/extract.spec.ts | 46 +++++----- lib/modules/manager/gradle/extract/catalog.ts | 8 +- .../extract/consistent-versions-plugin.ts | 2 +- lib/modules/manager/gradle/parser.spec.ts | 88 ++++++++++--------- lib/modules/manager/gradle/parser/handlers.ts | 16 ++-- lib/modules/manager/gradle/update.spec.ts | 2 +- lib/modules/manager/gradle/update.ts | 2 +- .../__snapshots__/extract.spec.ts.snap | 2 +- lib/modules/manager/leiningen/extract.spec.ts | 4 +- lib/modules/manager/leiningen/extract.ts | 2 +- lib/modules/manager/maven/extract.spec.ts | 6 +- lib/modules/manager/maven/extract.ts | 10 +-- lib/modules/manager/maven/update.ts | 2 +- .../manager/npm/post-update/pnpm.spec.ts | 4 +- lib/modules/manager/poetry/schema.ts | 6 +- .../sbt/__snapshots__/extract.spec.ts.snap | 14 +-- lib/modules/manager/sbt/extract.spec.ts | 4 +- lib/modules/manager/sbt/extract.ts | 2 +- lib/modules/manager/types.ts | 2 +- .../repository/updates/branch-name.spec.ts | 15 +++- lib/workers/repository/updates/branch-name.ts | 7 ++ lib/workers/types.ts | 1 + 26 files changed, 146 insertions(+), 120 deletions(-) diff --git a/lib/config/types.ts b/lib/config/types.ts index 4b7169d16869dc..3ae840fcf1b3a1 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -305,6 +305,7 @@ export interface RenovateConfig statusCheckNames?: Record; env?: UserEnv; logLevelRemap?: LogLevelRemap[]; + sharedVariableName?: string; } const CustomDatasourceFormats = ['json', 'plain', 'yaml', 'html'] as const; diff --git a/lib/modules/manager/cocoapods/extract.ts b/lib/modules/manager/cocoapods/extract.ts index 041c2a8a0aace5..50faed7450ac8b 100644 --- a/lib/modules/manager/cocoapods/extract.ts +++ b/lib/modules/manager/cocoapods/extract.ts @@ -36,12 +36,12 @@ export function parseLine(line: string): ParsedLine { const depName = result.subspec ? `${result.spec}/${result.subspec}` : result.spec; - const groupName = result.spec; + const specName = result.spec; if (depName) { result.depName = depName; } - if (groupName) { - result.groupName = groupName; + if (specName) { + result.specName = specName; } delete result.spec; delete result.subspec; @@ -96,7 +96,7 @@ export async function extractPackageFile( const parsedLine = parseLine(line); const { depName, - groupName, + specName, currentValue, git, tag, @@ -112,14 +112,14 @@ export async function extractPackageFile( const managerData = { lineNumber }; let dep: PackageDependency = { depName, - groupName, + sharedVariableName: specName, skipReason: 'unspecified-version', }; if (currentValue) { dep = { depName, - groupName, + sharedVariableName: specName, datasource: PodDatasource.id, currentValue, managerData, @@ -131,14 +131,14 @@ export async function extractPackageFile( } else { dep = { depName, - groupName, + sharedVariableName: specName, skipReason: 'git-dependency', }; } } else if (path) { dep = { depName, - groupName, + sharedVariableName: specName, skipReason: 'path-dependency', }; } diff --git a/lib/modules/manager/cocoapods/types.ts b/lib/modules/manager/cocoapods/types.ts index 74fef13b828c8f..311fb8d867ca32 100644 --- a/lib/modules/manager/cocoapods/types.ts +++ b/lib/modules/manager/cocoapods/types.ts @@ -1,6 +1,6 @@ export interface ParsedLine { depName?: string; - groupName?: string; + specName?: string; spec?: string; subspec?: string; currentValue?: string; diff --git a/lib/modules/manager/gradle/__snapshots__/parser.spec.ts.snap b/lib/modules/manager/gradle/__snapshots__/parser.spec.ts.snap index 571951909582d3..163f10d220ed67 100644 --- a/lib/modules/manager/gradle/__snapshots__/parser.spec.ts.snap +++ b/lib/modules/manager/gradle/__snapshots__/parser.spec.ts.snap @@ -5,11 +5,11 @@ exports[`modules/manager/gradle/parser calculations parses fixture from "gradle" { "currentValue": "1.5.2.RELEASE", "depName": "org.springframework.boot:spring-boot-gradle-plugin", - "groupName": "springBootVersion", "managerData": { "fileReplacePosition": 53, "packageFile": "build.gradle", }, + "sharedVariableName": "springBootVersion", }, { "currentValue": "1.2.3", diff --git a/lib/modules/manager/gradle/extract.spec.ts b/lib/modules/manager/gradle/extract.spec.ts index 7a0900ddfc2b3c..d8b398d56f0ecb 100644 --- a/lib/modules/manager/gradle/extract.spec.ts +++ b/lib/modules/manager/gradle/extract.spec.ts @@ -188,27 +188,27 @@ describe('modules/manager/gradle/extract', () => { { depName: 'javax.cache:cache-api', currentValue: '1.1.0', - groupName: 'Libraries.jCache', + sharedVariableName: 'Libraries.jCache', }, { depName: 'com.android.tools.build:gradle', currentValue: '4.1.2', - groupName: 'Libraries.Android.Tools.version', + sharedVariableName: 'Libraries.Android.Tools.version', }, { depName: 'androidx.test:core', currentValue: '1.3.0-rc01', - groupName: 'Libraries.Test.version', + sharedVariableName: 'Libraries.Test.version', }, { depName: 'androidx.test.espresso:espresso-core', currentValue: '3.3.0-rc01', - groupName: 'Libraries.Test.Espresso.version', + sharedVariableName: 'Libraries.Test.Espresso.version', }, { depName: 'androidx.test:core-ktx', currentValue: '1.3.0-rc01', - groupName: 'Libraries.Test.version', + sharedVariableName: 'Libraries.Test.version', }, ], }, @@ -218,7 +218,7 @@ describe('modules/manager/gradle/extract', () => { { depName: 'org.jetbrains.kotlin:kotlin-stdlib', currentValue: '1.8.10', - groupName: 'GradleDeps.Kotlin.version', + sharedVariableName: 'GradleDeps.Kotlin.version', }, ], }, @@ -228,12 +228,12 @@ describe('modules/manager/gradle/extract', () => { { depName: 'com.fasterxml.jackson.core:jackson-annotations', currentValue: '2.9.10', - groupName: 'Versions.jackson', + sharedVariableName: 'Versions.jackson', }, { depName: 'io.reactivex.rxjava2:rxjava', currentValue: '1.2.3', - groupName: 'Versions.rxjava', + sharedVariableName: 'Versions.rxjava', }, ], }, @@ -513,7 +513,7 @@ describe('modules/manager/gradle/extract', () => { deps: [ { depName: 'io.gitlab.arturbosch.detekt:detekt-formatting', - groupName: 'detekt', + sharedVariableName: 'detekt', currentValue: '1.17.0', managerData: { fileReplacePosition: 21, @@ -522,7 +522,7 @@ describe('modules/manager/gradle/extract', () => { }, { depName: 'io.kotest:kotest-assertions-core-jvm', - groupName: 'kotest', + sharedVariableName: 'kotest', currentValue: '4.6.0', managerData: { fileReplacePosition: 51, @@ -531,7 +531,7 @@ describe('modules/manager/gradle/extract', () => { }, { depName: 'io.kotest:kotest-runner-junit5', - groupName: 'kotest', + sharedVariableName: 'kotest', currentValue: '4.6.0', managerData: { fileReplacePosition: 51, @@ -655,7 +655,7 @@ describe('modules/manager/gradle/extract', () => { }, { depName: 'com.squareup.retrofit2:retrofit', - groupName: 'retro.fit', + sharedVariableName: 'retro.fit', currentValue: '2.8.2', managerData: { fileReplacePosition: 42, @@ -765,7 +765,7 @@ describe('modules/manager/gradle/extract', () => { deps: [ { depName: 'io.gitlab.arturbosch.detekt:detekt-formatting', - groupName: 'detekt', + sharedVariableName: 'detekt', currentValue: '1.18.1', managerData: { fileReplacePosition: 21, @@ -784,7 +784,7 @@ describe('modules/manager/gradle/extract', () => { fileReplacePosition: 21, packageFile: 'gradle/libs.versions.toml', }, - groupName: 'detekt', + sharedVariableName: 'detekt', fileReplacePosition: 21, }, ], @@ -808,7 +808,7 @@ describe('modules/manager/gradle/extract', () => { deps: [ { depName: 'junit:junit', - groupName: 'junit', + sharedVariableName: 'junit', currentValue: '1.4.9', managerData: { fileReplacePosition: 124, @@ -818,7 +818,7 @@ describe('modules/manager/gradle/extract', () => { }, { depName: 'mocha-junit:mocha-junit', - groupName: 'mocha.junit.reporter', + sharedVariableName: 'mocha.junit.reporter', currentValue: '2.0.2', managerData: { fileReplacePosition: 82, @@ -1020,7 +1020,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:lucene-core', depType: 'dependencies', fileReplacePosition: 22, - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', lockedVersion: '1.2.3', managerData: { fileReplacePosition: 22, @@ -1031,7 +1031,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:lucene-codecs', depType: 'dependencies', fileReplacePosition: 22, - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', lockedVersion: '1.2.3', managerData: { fileReplacePosition: 22, @@ -1128,7 +1128,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:a.c', currentValue: '2', lockedVersion: '1', - groupName: 'org.apache.lucene:a.*', + sharedVariableName: 'org.apache.lucene:a.*', fileReplacePosition: 65, depType: 'dependencies', }, @@ -1140,7 +1140,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:a.d', currentValue: '2', lockedVersion: '1', - groupName: 'org.apache.lucene:a.*', + sharedVariableName: 'org.apache.lucene:a.*', fileReplacePosition: 65, depType: 'dependencies', }, @@ -1152,7 +1152,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:d', currentValue: '3', lockedVersion: '1', - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', fileReplacePosition: 39, depType: 'dependencies', }, @@ -1164,7 +1164,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.lucene:e.f', currentValue: '3', lockedVersion: '1', - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', fileReplacePosition: 39, depType: 'dependencies', }, @@ -1176,7 +1176,7 @@ describe('modules/manager/gradle/extract', () => { depName: 'org.apache.foo-bar:a', currentValue: '5', lockedVersion: '1', - groupName: 'org.apache.foo*:*', + sharedVariableName: 'org.apache.foo*:*', fileReplacePosition: 113, depType: 'dependencies', }, diff --git a/lib/modules/manager/gradle/extract/catalog.ts b/lib/modules/manager/gradle/extract/catalog.ts index e4ed8d634266a6..36a21a5b80639e 100644 --- a/lib/modules/manager/gradle/extract/catalog.ts +++ b/lib/modules/manager/gradle/extract/catalog.ts @@ -188,7 +188,7 @@ function extractDependency({ versionSubContent: string; }): PackageDependency { if (is.string(descriptor)) { - const [groupName, name, currentValue] = descriptor.split(':'); + const [group, name, currentValue] = descriptor.split(':'); if (!currentValue) { return { depName, @@ -196,7 +196,7 @@ function extractDependency({ }; } return { - depName: `${groupName}:${name}`, + depName: `${group}:${name}`, currentValue, managerData: { fileReplacePosition: @@ -236,7 +236,7 @@ function extractDependency({ } if (isVersionPointer(descriptor.version)) { - dependency.groupName = normalizeAlias(descriptor.version.ref); + dependency.sharedVariableName = normalizeAlias(descriptor.version.ref); } return dependency; @@ -298,7 +298,7 @@ export function parseCatalog( dependency.skipReason = skipReason; } if (isVersionPointer(version) && dependency.commitMessageTopic) { - dependency.groupName = normalizeAlias(version.ref); + dependency.sharedVariableName = normalizeAlias(version.ref); delete dependency.commitMessageTopic; } diff --git a/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts b/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts index 4feeb371208802..22ec356576adbe 100644 --- a/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts +++ b/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts @@ -102,7 +102,7 @@ export function parseGcv( currentValue: propVerAndPos.version, lockedVersion: lockVersionAndDepType.version, depType: lockVersionAndDepType.depType, - groupName: propDepGlob, + sharedVariableName: propDepGlob, } satisfies PackageDependency; extractedDeps.push(newDep); // Remove from the lockfile map so the same lib will not be included in more generic globs later diff --git a/lib/modules/manager/gradle/parser.spec.ts b/lib/modules/manager/gradle/parser.spec.ts index 668c6b3ff188cb..36aa4b74a3e583 100644 --- a/lib/modules/manager/gradle/parser.spec.ts +++ b/lib/modules/manager/gradle/parser.spec.ts @@ -179,32 +179,32 @@ describe('modules/manager/gradle/parser', () => { expect(deps).toMatchObject([ { depName: 'org.slf4j:jcl-over-slf4j', - groupName: 'slfj4Version', + sharedVariableName: 'slfj4Version', currentValue: '2.0.0', }, { depName: 'org.jetbrains.kotlinx:kotlinx-coroutines-core', - groupName: 'libraries.releaseCoroutines', + sharedVariableName: 'libraries.releaseCoroutines', currentValue: '0.26.1-eap13', }, { depName: 'org.slf4j:slf4j-api', - groupName: 'slfj4Version', + sharedVariableName: 'slfj4Version', currentValue: '2.0.0', }, { depName: 'androidx.lifecycle:lifecycle-runtime-ktx', - groupName: 'lifecycle_version', + sharedVariableName: 'lifecycle_version', currentValue: '2.5.1', }, { depName: 'androidx.lifecycle:lifecycle-viewmodel-ktx', - groupName: 'lifecycle_version', + sharedVariableName: 'lifecycle_version', currentValue: '2.5.1', }, { depName: 'org.slf4j:slf4j-ext', - groupName: 'slfj4Version', + sharedVariableName: 'slfj4Version', currentValue: '2.0.0', }, ]); @@ -333,17 +333,17 @@ describe('modules/manager/gradle/parser', () => { expect(deps).toMatchObject([ { depName: 'org.slf4j:jcl-over-slf4j', - groupName: 'slfj4Version', + sharedVariableName: 'slfj4Version', currentValue: '2.0.0', }, { depName: 'org.jetbrains.kotlinx:kotlinx-coroutines-core', - groupName: 'libraries.releaseCoroutines', + sharedVariableName: 'libraries.releaseCoroutines', currentValue: '0.26.1-eap13', }, { depName: 'org.slf4j:slf4j-api', - groupName: 'slfj4Version', + sharedVariableName: 'slfj4Version', currentValue: '2.0.0', }, ]); @@ -372,18 +372,18 @@ describe('modules/manager/gradle/parser', () => { ${'foo = "1.2.3"'} | ${'"foo:bar:$foo@@@"'} | ${null} ${''} | ${'"foo:bar:$baz"'} | ${null} ${'foo = "1"; bar = "2"; baz = "3"'} | ${'"foo:bar:$foo.$bar.$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', skipReason: 'contains-variable' }} - ${'baz = "1.2.3"'} | ${'"foo:bar:$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} - ${'foo.bar = "1.2.3"'} | ${'"foo:bar:$foo.bar"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'foo.bar' }} + ${'baz = "1.2.3"'} | ${'"foo:bar:$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} + ${'foo.bar = "1.2.3"'} | ${'"foo:bar:$foo.bar"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'foo.bar' }} ${'foo = "1.2.3"'} | ${'"foo:bar_$foo:4.5.6"'} | ${{ depName: 'foo:bar_1.2.3', managerData: { fileReplacePosition: 28 } }} ${'foo = "bar"'} | ${'"foo:${foo}1:1"'} | ${{ depName: 'foo:bar1', currentValue: '1', managerData: { fileReplacePosition: 25 } }} ${'bar = "bar:1.2.3"'} | ${'"foo:$bar"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', skipReason: 'contains-variable' }} - ${'baz = "1.2.3"'} | ${'foobar = "foo:bar:$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'foobar = "foo:bar:$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'foo = "${bar}"; baz = "1.2.3"'} | ${'"foo:bar:${baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} - ${'baz = "1.2.3"'} | ${'"foo:bar:${ext[\'baz\']}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} - ${'baz = "1.2.3"'} | ${'"foo:bar:${ext.baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} - ${'baz = "1.2.3"'} | ${'"foo:bar:${project.ext[\'baz\']}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} - ${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${property("c")}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'c' }} - ${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${properties["c"]}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'c' }} + ${'baz = "1.2.3"'} | ${'"foo:bar:${ext[\'baz\']}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} + ${'baz = "1.2.3"'} | ${'"foo:bar:${ext.baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} + ${'baz = "1.2.3"'} | ${'"foo:bar:${project.ext[\'baz\']}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} + ${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${property("c")}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'c' }} + ${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${properties["c"]}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'c' }} `('$def | $str', ({ def, str, output }) => { const { deps } = parseGradle([def, str].join('\n')); expect(deps).toMatchObject([output].filter(is.truthy)); @@ -434,7 +434,11 @@ describe('modules/manager/gradle/parser', () => { `; const { deps } = parseGradle(input); expect(deps).toMatchObject([ - { depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }, + { + depName: 'foo:bar', + currentValue: '1.2.3', + sharedVariableName: 'baz', + }, ]); }); }); @@ -452,7 +456,7 @@ describe('modules/manager/gradle/parser', () => { ${''} | ${'kotlin("foo", version = "1.2.3")'} | ${output} ${'some = "foo"'} | ${'kotlin(some, version = "1.2.3")'} | ${output} ${'some = "foo"'} | ${'kotlin("${some}", "1.2.3")'} | ${output} - ${'baz = "1.2.3"'} | ${'kotlin("foo", baz)'} | ${{ ...output, groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'kotlin("foo", baz)'} | ${{ ...output, sharedVariableName: 'baz' }} ${'baz = "1.2.3"'} | ${'kotlin("foo", version = baz)'} | ${output} ${'baz = "1.2.3"'} | ${'kotlin("foo", property("baz"))'} | ${output} ${'baz = "1.2.3"'} | ${'kotlin("foo", "${baz}456")'} | ${{ skipReason: 'unspecified-version' }} @@ -473,21 +477,21 @@ describe('modules/manager/gradle/parser', () => { ${''} | ${'group: "foo", name: "bar", version: "1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${''} | ${'group: "foo", name: "bar", version: baz'} | ${null} ${''} | ${'group: "foo", name: "bar", version: "1.2.3@@@"'} | ${null} - ${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: baz'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: baz'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'some = "foo"'} | ${'group: property("some"), name: property("some"), version: "1.2.3"'} | ${{ depName: 'foo:foo', currentValue: '1.2.3' }} ${'some = "foo"'} | ${'group: some, name: some, version: "1.2.3"'} | ${{ depName: 'foo:foo', currentValue: '1.2.3' }} ${'some = "foo"'} | ${'group: "${some}", name: "${some}", version: "1.2.3"'} | ${{ depName: 'foo:foo', currentValue: '1.2.3' }} - ${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: "${baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: "${baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: "${baz}456"'} | ${{ depName: 'foo:bar', skipReason: 'unspecified-version' }} ${''} | ${'(group: "foo", name: "bar", version: "1.2.3", classifier: "sources")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${''} | ${'(group: "foo", name: "bar", version: "1.2.3") {exclude module: "spring-jcl"}'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${''} | ${"implementation platform(group: 'foo', name: 'bar', version: '1.2.3')"} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${''} | ${'(group = "foo", name = "bar", version = "1.2.3")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} - ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = baz)'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = baz)'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'some = "foo"'} | ${'(group = some, name = some, version = "1.2.3")'} | ${{ depName: 'foo:foo', currentValue: '1.2.3' }} ${'some = "foo"'} | ${'(group = "${some}", name = "${some}", version = "1.2.3")'} | ${{ depName: 'foo:foo', currentValue: '1.2.3' }} ${'some = "foo"'} | ${'(group = "${some}" + some, name = some + "bar" + some, version = "1.2.3")'} | ${{ depName: 'foofoo:foobarfoo', currentValue: '1.2.3' }} - ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = "${baz}")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = "${baz}")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = "${baz}456")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3456', skipReason: 'unspecified-version' }} ${'baz = "1.2.3"'} | ${'(group = "foo", name = "bar", version = baz + "456")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3456', skipReason: 'unspecified-version' }} ${''} | ${'(group = "foo", name = "bar", version = "1.2.3", changing: true)'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} @@ -515,17 +519,17 @@ describe('modules/manager/gradle/parser', () => { { depName: 'org.apache.activemq:activemq-broker', currentValue: '5.8.0', - groupName: 'activemq_version', + sharedVariableName: 'activemq_version', }, { depName: 'org.apache.activemq:activemq-kahadb-store', currentValue: '5.8.0', - groupName: 'activemq_version', + sharedVariableName: 'activemq_version', }, { depName: 'org.apache.activemq:activemq-stomp', currentValue: '5.8.0', - groupName: 'activemq_version', + sharedVariableName: 'activemq_version', }, ]); }); @@ -535,16 +539,16 @@ describe('modules/manager/gradle/parser', () => { { depName: 'foo:bar1', currentValue: '1.2.3', - groupName: 'foo:1.2.3', + sharedVariableName: 'foo:1.2.3', }, { depName: 'foo:bar2', currentValue: '1.2.3', - groupName: 'foo:1.2.3', + sharedVariableName: 'foo:1.2.3', }, ]; const validOutput1 = validOutput.map((dep) => { - return { ...dep, groupName: 'baz' }; + return { ...dep, sharedVariableName: 'baz' }; }); it.each` @@ -584,7 +588,7 @@ describe('modules/manager/gradle/parser', () => { ${''} | ${'id("foo.bar") version("1.2.3")'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3' }} ${''} | ${'id("foo.bar") version "1.2.3"'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3' }} ${''} | ${'id "foo.bar" version "$baz"'} | ${{ depName: 'foo.bar', skipReason: 'unspecified-version', currentValue: 'baz' }} - ${'baz = "1.2.3"'} | ${'id "foo.bar" version "$baz"'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'id "foo.bar" version "$baz"'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'baz = "1.2.3"'} | ${'id("foo.bar") version "$baz"'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3' }} ${''} | ${'id "foo.bar" version "x${ab}cd"'} | ${{ depName: 'foo.bar', skipReason: 'unspecified-version' }} ${''} | ${'id("foo.bar") version "$baz"'} | ${{ depName: 'foo.bar', skipReason: 'unspecified-version', currentValue: 'baz' }} @@ -597,7 +601,7 @@ describe('modules/manager/gradle/parser', () => { ${'baz = "1.2.3"'} | ${'id("foo.bar") version baz'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3' }} ${'baz = "1.2.3"'} | ${'id("foo.bar").version(baz)'} | ${{ depName: 'foo.bar', packageName: 'foo.bar:foo.bar.gradle.plugin', currentValue: '1.2.3' }} ${''} | ${'kotlin("jvm") version "1.3.71"'} | ${{ depName: 'org.jetbrains.kotlin.jvm', packageName: 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin', currentValue: '1.3.71' }} - ${'baz = "1.3.71"'} | ${'kotlin("jvm") version baz'} | ${{ depName: 'org.jetbrains.kotlin.jvm', packageName: 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin', currentValue: '1.3.71', groupName: 'baz' }} + ${'baz = "1.3.71"'} | ${'kotlin("jvm") version baz'} | ${{ depName: 'org.jetbrains.kotlin.jvm', packageName: 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin', currentValue: '1.3.71', sharedVariableName: 'baz' }} `('$def | $input', ({ def, input, output }) => { const { deps } = parseGradle([def, input].join('\n')); expect(deps).toMatchObject([output].filter(is.truthy)); @@ -735,7 +739,7 @@ describe('modules/manager/gradle/parser', () => { ${'f = "foo"; b = "bar"'} | ${'library("foo.bar", "${f}", "${b}").version("1.2.3")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${'f = "foo"; b = "bar"; v = "1.2.3"'} | ${'library("foo.bar", property("f"), "${b}").version(v)'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${'f = "foo"; b = "bar"'} | ${'library("foo.bar", "${f}" + f, "${b}").version("1.2.3")'} | ${{ depName: 'foofoo:bar', currentValue: '1.2.3' }} - ${'version("baz", "1.2.3")'} | ${'library("foo.bar", "foo", "bar").versionRef("baz")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }} + ${'version("baz", "1.2.3")'} | ${'library("foo.bar", "foo", "bar").versionRef("baz")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'library("foo-bar_baz-qux", "foo", "bar")'} | ${'"${libs.foo.bar.baz.qux}:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }} ${''} | ${'library(["foo.bar", "foo", "bar"]).version("1.2.3")'} | ${null} ${''} | ${'library("foo", "bar", "baz", "qux").version("1.2.3")'} | ${null} @@ -928,7 +932,7 @@ describe('modules/manager/gradle/parser', () => { ${''} | ${'detekt { toolVersion = "1.2.3" }'} | ${{ depName: 'detekt', packageName: GRADLE_PLUGINS['detekt'][1], currentValue: '1.2.3' }} ${''} | ${'findbugs { toolVersion = "1.2.3" }'} | ${{ depName: 'findbugs', packageName: GRADLE_PLUGINS['findbugs'][1], currentValue: '1.2.3' }} ${''} | ${'googleJavaFormat { toolVersion = "1.2.3" }'} | ${{ depName: 'googleJavaFormat', packageName: GRADLE_PLUGINS['googleJavaFormat'][1], currentValue: '1.2.3' }} - ${'baz = "1.2.3"'} | ${'jacoco { toolVersion = baz }'} | ${{ depName: 'jacoco', packageName: GRADLE_PLUGINS['jacoco'][1], currentValue: '1.2.3', groupName: 'baz' }} + ${'baz = "1.2.3"'} | ${'jacoco { toolVersion = baz }'} | ${{ depName: 'jacoco', packageName: GRADLE_PLUGINS['jacoco'][1], currentValue: '1.2.3', sharedVariableName: 'baz' }} ${'baz = "1.2.3"'} | ${'jacoco { toolVersion = property("baz") }'} | ${{ depName: 'jacoco', packageName: GRADLE_PLUGINS['jacoco'][1], currentValue: '1.2.3' }} ${''} | ${'lombok { version = "1.2.3" }'} | ${{ depName: 'lombok', packageName: GRADLE_PLUGINS['lombok'][1], currentValue: '1.2.3' }} ${''} | ${'lombok { version.set("1.2.3") }'} | ${{ depName: 'lombok', packageName: GRADLE_PLUGINS['lombok'][1], currentValue: '1.2.3' }} @@ -982,7 +986,7 @@ describe('modules/manager/gradle/parser', () => { deps: [ { depName: 'org.slf4j:slf4j-api', - groupName: 'Versions.baz', + sharedVariableName: 'Versions.baz', currentValue: '1.2.3', }, { @@ -991,17 +995,17 @@ describe('modules/manager/gradle/parser', () => { }, { depName: 'androidx.core:core-ktx', - groupName: 'Versions.baz', + sharedVariableName: 'Versions.baz', currentValue: '1.2.3', }, { depName: 'androidx.webkit:webkit', - groupName: 'Versions.baz', + sharedVariableName: 'Versions.baz', currentValue: '1.2.3', }, { depName: 'foo:bar', - groupName: 'Versions.baz', + sharedVariableName: 'Versions.baz', currentValue: '1.2.3', }, ], @@ -1055,22 +1059,22 @@ describe('modules/manager/gradle/parser', () => { { depName: 'org.jetbrains.kotlin:kotlin-stdlib-jdk7', currentValue: '1.5.31', - groupName: 'Deps.kotlinVersion', + sharedVariableName: 'Deps.kotlinVersion', }, { depName: 'androidx.test:core', currentValue: '1.3.0-rc01', - groupName: 'Deps.Test.version', + sharedVariableName: 'Deps.Test.version', }, { depName: 'androidx.test.espresso:espresso-core', currentValue: '3.3.0-rc01', - groupName: 'Deps.Test.Espresso.Release.version', + sharedVariableName: 'Deps.Test.Espresso.Release.version', }, { depName: 'androidx.test:core-ktx', currentValue: '1.3.0-rc01', - groupName: 'Deps.Test.version', + sharedVariableName: 'Deps.Test.version', }, ], }); @@ -1107,7 +1111,7 @@ describe('modules/manager/gradle/parser', () => { { depName: 'com.h2database:h2', currentValue: '2.0.206', - groupName: 'ModuleConfiguration.Build.Database.h2Version', + sharedVariableName: 'ModuleConfiguration.Build.Database.h2Version', }, ], }); diff --git a/lib/modules/manager/gradle/parser/handlers.ts b/lib/modules/manager/gradle/parser/handlers.ts index 229671b249eaed..1a20670548e920 100644 --- a/lib/modules/manager/gradle/parser/handlers.ts +++ b/lib/modules/manager/gradle/parser/handlers.ts @@ -40,7 +40,7 @@ export function handleAssignment(ctx: Ctx): Ctx { // = string value const dep = parseDependencyString(valTokens[0].value); if (dep) { - dep.groupName = key; + dep.sharedVariableName = key; dep.managerData = { fileReplacePosition: valTokens[0].offset + dep.depName!.length + 1, packageFile: ctx.packageFile, @@ -82,7 +82,7 @@ export function handleDepString(ctx: Ctx): Ctx { fileReplacePosition = varData.fileReplacePosition; if (varData.value === dep.currentValue) { dep.managerData = { fileReplacePosition, packageFile }; - dep.groupName = varData.key; + dep.sharedVariableName = varData.key; } } } @@ -102,7 +102,7 @@ export function handleDepString(ctx: Ctx): Ctx { fileReplacePosition = lastToken.offset + lastToken.value.lastIndexOf(dep.currentValue); } - delete dep.groupName; + delete dep.sharedVariableName; } else { dep.skipReason = 'contains-variable'; } @@ -143,7 +143,7 @@ export function handleKotlinShortNotationDep(ctx: Ctx): Ctx { } else if (versionTokens[0].type === 'symbol') { const varData = findVariable(versionTokens[0].value, ctx); if (varData) { - dep.groupName = varData.key; + dep.sharedVariableName = varData.key; dep.currentValue = varData.value; dep.managerData = { fileReplacePosition: varData.fileReplacePosition, @@ -181,7 +181,7 @@ export function handleLongFormDep(ctx: Ctx): Ctx { } else if (versionTokens[0].type === 'symbol') { const varData = findVariable(versionTokens[0].value, ctx); if (varData) { - dep.groupName = varData.key; + dep.sharedVariableName = varData.key; dep.managerData = { fileReplacePosition: varData.fileReplacePosition, packageFile: varData.packageFile, @@ -190,7 +190,7 @@ export function handleLongFormDep(ctx: Ctx): Ctx { } else { // = string value if (methodName?.[0]?.value === 'dependencySet') { - dep.groupName = `${groupId}:${version}`; + dep.sharedVariableName = `${groupId}:${version}`; } dep.managerData = { fileReplacePosition: versionTokens[0].offset, @@ -231,7 +231,7 @@ export function handlePlugin(ctx: Ctx): Ctx { } else if (pluginVersion[0].type === 'symbol') { const varData = findVariable(pluginVersion[0].value, ctx); if (varData) { - dep.groupName = varData.key; + dep.sharedVariableName = varData.key; dep.currentValue = varData.value; dep.managerData = { fileReplacePosition: varData.fileReplacePosition, @@ -413,7 +413,7 @@ export function handleImplicitGradlePlugin(ctx: Ctx): Ctx { } else if (versionTokens[0].type === 'symbol') { const varData = findVariable(versionTokens[0].value, ctx); if (varData) { - dep.groupName = varData.key; + dep.sharedVariableName = varData.key; dep.currentValue = varData.value; dep.managerData = { fileReplacePosition: varData.fileReplacePosition, diff --git a/lib/modules/manager/gradle/update.spec.ts b/lib/modules/manager/gradle/update.spec.ts index 4d0a77623d5810..cd46e12ca1a167 100644 --- a/lib/modules/manager/gradle/update.spec.ts +++ b/lib/modules/manager/gradle/update.spec.ts @@ -23,7 +23,7 @@ describe('modules/manager/gradle/update', () => { upgrade: { currentValue: '1.2.3', newValue: '1.2.5', - groupName: 'group', + sharedVariableName: 'group', managerData: { fileReplacePosition: 3, }, diff --git a/lib/modules/manager/gradle/update.ts b/lib/modules/manager/gradle/update.ts index 0839c2c7e20bb3..4286535ece0b47 100644 --- a/lib/modules/manager/gradle/update.ts +++ b/lib/modules/manager/gradle/update.ts @@ -23,7 +23,7 @@ export function updateDependency({ if (version === newValue) { return fileContent; } - if (version === currentValue || upgrade.groupName) { + if (version === currentValue || upgrade.sharedVariableName) { // TODO: types (#22198) return `${leftPart}${newValue}${restPart}`; } diff --git a/lib/modules/manager/leiningen/__snapshots__/extract.spec.ts.snap b/lib/modules/manager/leiningen/__snapshots__/extract.spec.ts.snap index 53d474d9490a58..147031d8545874 100644 --- a/lib/modules/manager/leiningen/__snapshots__/extract.spec.ts.snap +++ b/lib/modules/manager/leiningen/__snapshots__/extract.spec.ts.snap @@ -116,13 +116,13 @@ exports[`modules/manager/leiningen/extract extractPackageFile 1`] = ` "datasource": "clojure", "depName": "clj-stacktrace:clj-stacktrace", "depType": "dependencies", - "groupName": "clj-stacktrace-version", "registryUrls": [ "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/internal", ], + "sharedVariableName": "clj-stacktrace-version", }, { "currentValue": "0.12.0", diff --git a/lib/modules/manager/leiningen/extract.spec.ts b/lib/modules/manager/leiningen/extract.spec.ts index 76e3d765e03d4e..867a2a5d964dcd 100644 --- a/lib/modules/manager/leiningen/extract.spec.ts +++ b/lib/modules/manager/leiningen/extract.spec.ts @@ -38,7 +38,7 @@ describe('modules/manager/leiningen/extract', () => { datasource: ClojureDatasource.id, depName: 'foo:bar', currentValue: '1.2.3', - groupName: 'baz', + sharedVariableName: 'baz', }, ]); expect( @@ -86,7 +86,7 @@ describe('modules/manager/leiningen/extract', () => { { depName: 'clj-stacktrace:clj-stacktrace', currentValue: '0.2.4', - groupName: 'clj-stacktrace-version', + sharedVariableName: 'clj-stacktrace-version', }, { depName: 'clj-time:clj-time', diff --git a/lib/modules/manager/leiningen/extract.ts b/lib/modules/manager/leiningen/extract.ts index 680b5f14cb025f..54ede6bd46fe68 100644 --- a/lib/modules/manager/leiningen/extract.ts +++ b/lib/modules/manager/leiningen/extract.ts @@ -58,7 +58,7 @@ export function extractFromVectors( datasource: ClojureDatasource.id, depName, currentValue, - groupName: varName, + sharedVariableName: varName, }); } } else { diff --git a/lib/modules/manager/maven/extract.spec.ts b/lib/modules/manager/maven/extract.spec.ts index 3efc9d99aea9fa..f564c877d543a3 100644 --- a/lib/modules/manager/maven/extract.spec.ts +++ b/lib/modules/manager/maven/extract.spec.ts @@ -476,7 +476,7 @@ describe('modules/manager/maven/extract', () => { depType: 'compile', editFile: 'parent.pom.xml', fileReplacePosition: 470, - groupName: 'quuxVersion', + sharedVariableName: 'quuxVersion', registryUrls: [ 'http://example.com/', 'http://example.com/nexus/xyz', @@ -697,12 +697,12 @@ describe('modules/manager/maven/extract', () => { { depName: 'org.example:quux', currentValue: '1.2.3.4', - groupName: 'quuxVersion', + sharedVariableName: 'quuxVersion', }, { depName: 'org.example:quux-test', currentValue: '1.2.3.4', - groupName: 'quuxVersion', + sharedVariableName: 'quuxVersion', }, { depName: 'org.example:quuz', diff --git a/lib/modules/manager/maven/extract.ts b/lib/modules/manager/maven/extract.ts index ef06fe3911228c..939e31e25c1e8a 100644 --- a/lib/modules/manager/maven/extract.ts +++ b/lib/modules/manager/maven/extract.ts @@ -224,7 +224,7 @@ function applyPropsInternal( let fileReplacePosition = dep.fileReplacePosition; let propSource = dep.propSource; - let groupName: string | null = null; + let sharedVariableName: string | null = null; const currentValue = dep.currentValue!.replace( regEx(/^\${[^}]*?}$/), (substr) => { @@ -232,8 +232,8 @@ function applyPropsInternal( // TODO: wrong types here, props is already `MavenProp` const propValue = (props as any)[propKey] as MavenProp; if (propValue) { - if (!groupName) { - groupName = propKey; + if (!sharedVariableName) { + sharedVariableName = propKey; } fileReplacePosition = propValue.fileReplacePosition; propSource = @@ -261,8 +261,8 @@ function applyPropsInternal( currentValue, }; - if (groupName) { - result.groupName = groupName; + if (sharedVariableName) { + result.sharedVariableName = sharedVariableName; } if (propSource && depPackageFile !== propSource) { diff --git a/lib/modules/manager/maven/update.ts b/lib/modules/manager/maven/update.ts index b22261c0a85162..413892c462cf83 100644 --- a/lib/modules/manager/maven/update.ts +++ b/lib/modules/manager/maven/update.ts @@ -25,7 +25,7 @@ export function updateAtPosition( if (version === newValue) { return fileContent; } - if (version === currentValue || upgrade.groupName) { + if (version === currentValue || upgrade.sharedVariableName) { // TODO: validate newValue (#22198) const replacedPart = versionPart.replace(version, newValue!); return leftPart + replacedPart + restPart; diff --git a/lib/modules/manager/npm/post-update/pnpm.spec.ts b/lib/modules/manager/npm/post-update/pnpm.spec.ts index 6c9d28db1b8a50..41c7e9dffac96c 100644 --- a/lib/modules/manager/npm/post-update/pnpm.spec.ts +++ b/lib/modules/manager/npm/post-update/pnpm.spec.ts @@ -104,13 +104,13 @@ describe('modules/manager/npm/post-update/pnpm', () => { fs.readLocalFile.mockResolvedValue('package-lock-contents'); const res = await pnpmHelper.generateLockFile('some-folder', {}, config, [ { - groupName: 'some-group', + sharedVariableName: 'some-group', packageName: 'some-dep', newVersion: '1.1.0', isLockfileUpdate: true, }, { - groupName: 'some-group', + sharedVariableName: 'some-group', packageName: 'some-other-dep', newVersion: '1.1.0', isLockfileUpdate: false, diff --git a/lib/modules/manager/poetry/schema.ts b/lib/modules/manager/poetry/schema.ts index 6e650c21b2d0fc..eb4df77fca1858 100644 --- a/lib/modules/manager/poetry/schema.ts +++ b/lib/modules/manager/poetry/schema.ts @@ -195,9 +195,9 @@ export const PoetryGroupDependencies = LooseRecord( .transform(({ dependencies }) => dependencies), ).transform((record) => { const deps: PackageDependency[] = []; - for (const [groupName, group] of Object.entries(record)) { - for (const dep of Object.values(group)) { - dep.depType = groupName; + for (const [name, val] of Object.entries(record)) { + for (const dep of Object.values(val)) { + dep.depType = name; deps.push(dep); } } diff --git a/lib/modules/manager/sbt/__snapshots__/extract.spec.ts.snap b/lib/modules/manager/sbt/__snapshots__/extract.spec.ts.snap index e369d665da0fc2..87d51705bf4989 100644 --- a/lib/modules/manager/sbt/__snapshots__/extract.spec.ts.snap +++ b/lib/modules/manager/sbt/__snapshots__/extract.spec.ts.snap @@ -22,9 +22,9 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati "currentValue": "1.2.3", "datasource": "sbt-package", "depName": "com.abc:abc", - "groupName": "abcVersion", "packageName": "com.abc:abc", "registryUrls": [], + "sharedVariableName": "abcVersion", "variableName": "abcVersion", }, ], @@ -57,36 +57,36 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati "currentValue": "1.2.3", "datasource": "sbt-package", "depName": "com.abc:abc", - "groupName": "abcVersion", "packageName": "com.abc:abc", "registryUrls": [], + "sharedVariableName": "abcVersion", "variableName": "abcVersion", }, { "currentValue": "1.2.3", "datasource": "sbt-package", "depName": "com.abc:abc-a", - "groupName": "abcVersion", "packageName": "com.abc:abc-a", "registryUrls": [], + "sharedVariableName": "abcVersion", "variableName": "abcVersion", }, { "currentValue": "1.2.3", "datasource": "sbt-package", "depName": "com.abc:abc-b", - "groupName": "abcVersion", "packageName": "com.abc:abc-b", "registryUrls": [], + "sharedVariableName": "abcVersion", "variableName": "abcVersion", }, { "currentValue": "1.2.3", "datasource": "sbt-package", "depName": "com.abc:abc-c", - "groupName": "abcVersion", "packageName": "com.abc:abc-c", "registryUrls": [], + "sharedVariableName": "abcVersion", "variableName": "abcVersion", }, ], @@ -240,7 +240,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene "datasource": "sbt-package", "depName": "org.example:grault", "depType": "Test", - "groupName": "versionExample", "packageName": "org.example:grault", "registryUrls": [ "https://example.com/repos/1/", @@ -249,6 +248,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene "https://example.com/repos/4/", "https://example.com/repos/5/", ], + "sharedVariableName": "versionExample", "variableName": "versionExample", }, { @@ -401,7 +401,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca "datasource": "sbt-package", "depName": "org.example:grault", "depType": "Test", - "groupName": "versionExample", "packageName": "org.example:grault", "registryUrls": [ "https://example.com/repos/1/", @@ -410,6 +409,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca "https://example.com/repos/4/", "https://example.com/repos/5/", ], + "sharedVariableName": "versionExample", "variableName": "versionExample", }, { diff --git a/lib/modules/manager/sbt/extract.spec.ts b/lib/modules/manager/sbt/extract.spec.ts index 7410b282ae382c..03f3cbf232c2f7 100644 --- a/lib/modules/manager/sbt/extract.spec.ts +++ b/lib/modules/manager/sbt/extract.spec.ts @@ -116,7 +116,7 @@ describe('modules/manager/sbt/extract', () => { deps: [ { currentValue: '1.2.3', - groupName: 'version', + sharedVariableName: 'version', }, ], }); @@ -137,7 +137,7 @@ describe('modules/manager/sbt/extract', () => { datasource: 'sbt-plugin', depName: 'com.github.gseitz:sbt-release', depType: 'plugin', - groupName: 'sbtReleaseVersion', + sharedVariableName: 'sbtReleaseVersion', packageName: 'com.github.gseitz:sbt-release', registryUrls: [], variableName: 'sbtReleaseVersion', diff --git a/lib/modules/manager/sbt/extract.ts b/lib/modules/manager/sbt/extract.ts index fd5a9173769dd0..80bfc399ee0acf 100644 --- a/lib/modules/manager/sbt/extract.ts +++ b/lib/modules/manager/sbt/extract.ts @@ -218,7 +218,7 @@ function depHandler(ctx: Ctx): Ctx { } if (variableName) { - dep.groupName = variableName; + dep.sharedVariableName = variableName; dep.variableName = variableName; } diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index a1e8ba2824d9df..7e6cd5fdd09aeb 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -114,7 +114,7 @@ export interface PackageDependency> depName?: string; depType?: string; fileReplacePosition?: number; - groupName?: string; + sharedVariableName?: string; lineNumber?: number; packageName?: string; target?: string; diff --git a/lib/workers/repository/updates/branch-name.spec.ts b/lib/workers/repository/updates/branch-name.spec.ts index a4b4dd5993954e..5feb61bb8e0e57 100644 --- a/lib/workers/repository/updates/branch-name.spec.ts +++ b/lib/workers/repository/updates/branch-name.spec.ts @@ -3,9 +3,22 @@ import { generateBranchName } from './branch-name'; describe('workers/repository/updates/branch-name', () => { describe('getBranchName()', () => { - it('uses groupName if no slug defined', () => { + it('falls back to sharedVariableName if no groupName', () => { + const upgrade: RenovateConfig = { + sharedVariableName: 'some variable name', + group: { + branchName: '{{groupSlug}}-{{branchTopic}}', + branchTopic: 'grouptopic', + }, + }; + generateBranchName(upgrade); + expect(upgrade.branchName).toBe('some-variable-name-grouptopic'); + }); + + it('uses groupName if no slug defined, ignores sharedVariableName', () => { const upgrade: RenovateConfig = { groupName: 'some group name', + sharedVariableName: 'some variable name', group: { branchName: '{{groupSlug}}-{{branchTopic}}', branchTopic: 'grouptopic', diff --git a/lib/workers/repository/updates/branch-name.ts b/lib/workers/repository/updates/branch-name.ts index d151c0772b8c24..4f6356ce870c6c 100644 --- a/lib/workers/repository/updates/branch-name.ts +++ b/lib/workers/repository/updates/branch-name.ts @@ -57,6 +57,13 @@ export function generateBranchName(update: RenovateConfig): void { // Check whether to use a group name const newMajor = String(update.newMajor); const newMinor = String(update.newMinor); + if (!update.groupName && update.sharedVariableName) { + logger.debug( + `Using sharedVariableName=${update.sharedVariableName} as groupName for depName=${update.depName}`, + ); + update.groupName = update.sharedVariableName; + } + update.groupName ??= update.sharedVariableName; if (update.groupName) { update.groupName = template.compile(update.groupName, update); logger.trace('Using group branchName template'); diff --git a/lib/workers/types.ts b/lib/workers/types.ts index e4c6477b45f662..152cb3ae6ce494 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -50,6 +50,7 @@ export interface BranchUpgradeConfig group?: GroupConfig; groupName?: string; groupSlug?: string; + manager: string; packageFile?: string; lockFile?: string; From b93b82f0fd7f8623d75eeb4275aad7fcb263096b Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 14 Dec 2024 11:33:14 +0100 Subject: [PATCH 2/3] Update branch-name.ts Co-authored-by: Michael Kriese --- lib/workers/repository/updates/branch-name.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/workers/repository/updates/branch-name.ts b/lib/workers/repository/updates/branch-name.ts index 4f6356ce870c6c..36f085dd1fe08d 100644 --- a/lib/workers/repository/updates/branch-name.ts +++ b/lib/workers/repository/updates/branch-name.ts @@ -63,7 +63,6 @@ export function generateBranchName(update: RenovateConfig): void { ); update.groupName = update.sharedVariableName; } - update.groupName ??= update.sharedVariableName; if (update.groupName) { update.groupName = template.compile(update.groupName, update); logger.trace('Using group branchName template'); From 05a6acf6769705c6e648b233e482cc706b96931e Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 14 Dec 2024 11:33:21 +0100 Subject: [PATCH 3/3] Update types.ts Co-authored-by: Michael Kriese --- lib/workers/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 152cb3ae6ce494..e4c6477b45f662 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -50,7 +50,6 @@ export interface BranchUpgradeConfig group?: GroupConfig; groupName?: string; groupSlug?: string; - manager: string; packageFile?: string; lockFile?: string;