diff --git a/lib/config/types.ts b/lib/config/types.ts index 0798f99d7ca662d1c38fa25654cc040dc6727c8b..7bf0bcaf0237f262b20bce2c0f4808fec3c5d682 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -309,6 +309,7 @@ export interface RenovateConfig branchTopic?: string; additionalBranchPrefix?: string; + 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 041c2a8a0aace5e0c0c552164313c5b04372f180..50faed7450ac8b5c8d07d976db18f917166707ff 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 74fef13b828c8fe927549a066f1fb8de95cb563a..311fb8d867ca32b23320986afd5ac33c5afdb4bc 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/extract.spec.ts b/lib/modules/manager/gradle/extract.spec.ts index bd11d3a32ac66ccc0d20dd48dfb7070f6a326239..25c24846e3805cfc64d21409f744e483ab2da64b 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, @@ -627,6 +627,58 @@ describe('modules/manager/gradle/extract', () => { ), ).toBeNull(); }); + + it('deletes commit message for plugins with version reference', async () => { + const fsMock = { + 'gradle/libs.versions.toml': codeBlock` + [versions] + detekt = "1.18.1" + + [plugins] + detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } + + [libraries] + detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" } + `, + }; + mockFs(fsMock); + + const res = await extractAllPackageFiles( + partial<ExtractConfig>(), + Object.keys(fsMock), + ); + expect(res).toMatchObject([ + { + packageFile: 'gradle/libs.versions.toml', + deps: [ + { + depName: 'io.gitlab.arturbosch.detekt:detekt-formatting', + sharedVariableName: 'detekt', + currentValue: '1.18.1', + managerData: { + fileReplacePosition: 21, + packageFile: 'gradle/libs.versions.toml', + }, + fileReplacePosition: 21, + }, + { + depType: 'plugin', + depName: 'io.gitlab.arturbosch.detekt', + packageName: + 'io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin', + registryUrls: ['https://plugins.gradle.org/m2/'], + currentValue: '1.18.1', + managerData: { + fileReplacePosition: 21, + packageFile: 'gradle/libs.versions.toml', + }, + sharedVariableName: 'detekt', + fileReplacePosition: 21, + }, + ], + }, + ]); + }); }); describe('apply from', () => { @@ -817,7 +869,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, @@ -828,7 +880,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, @@ -869,5 +921,117 @@ describe('modules/manager/gradle/extract', () => { ); expect(res).toBeNull(); }); + + it('supports multiple levels of glob', async () => { + const fsMock = { + 'versions.props': codeBlock` + org.apache.* = 4 + org.apache.lucene:* = 3 + org.apache.lucene:a.* = 2 + org.apache.lucene:a.b = 1 + org.apache.foo*:* = 5 + `, + 'versions.lock': codeBlock` + # Run ./gradlew --write-locks to regenerate this file + org.apache.solr:x.y:1 (10 constraints: 95be0c15) + org.apache.lucene:a.b:1 (10 constraints: 95be0c15) + org.apache.lucene:a.c:1 (10 constraints: 95be0c15) + org.apache.lucene:a.d:1 (10 constraints: 95be0c15) + org.apache.lucene:d:1 (10 constraints: 95be0c15) + org.apache.lucene:e.f:1 (10 constraints: 95be0c15) + org.apache.foo-bar:a:1 (10 constraints: 95be0c15) + `, + }; + mockFs(fsMock); + + const res = await extractAllPackageFiles( + partial<ExtractConfig>(), + Object.keys(fsMock), + ); + + // Each lock dep is only present once, with highest prio for exact prop match, then globs from longest to shortest + expect(res).toMatchObject([ + { + packageFile: 'versions.lock', + deps: [], + }, + { + packageFile: 'versions.props', + deps: [ + { + managerData: { + packageFile: 'versions.props', + fileReplacePosition: 91, + }, + depName: 'org.apache.lucene:a.b', + currentValue: '1', + lockedVersion: '1', + fileReplacePosition: 91, + depType: 'dependencies', + }, + { + managerData: { + packageFile: 'versions.props', + fileReplacePosition: 65, + }, + depName: 'org.apache.lucene:a.c', + currentValue: '2', + lockedVersion: '1', + sharedVariableName: 'org.apache.lucene:a.*', + fileReplacePosition: 65, + depType: 'dependencies', + }, + { + managerData: { + packageFile: 'versions.props', + fileReplacePosition: 65, + }, + depName: 'org.apache.lucene:a.d', + currentValue: '2', + lockedVersion: '1', + sharedVariableName: 'org.apache.lucene:a.*', + fileReplacePosition: 65, + depType: 'dependencies', + }, + { + managerData: { + packageFile: 'versions.props', + fileReplacePosition: 39, + }, + depName: 'org.apache.lucene:d', + currentValue: '3', + lockedVersion: '1', + sharedVariableName: 'org.apache.lucene:*', + fileReplacePosition: 39, + depType: 'dependencies', + }, + { + managerData: { + packageFile: 'versions.props', + fileReplacePosition: 39, + }, + depName: 'org.apache.lucene:e.f', + currentValue: '3', + lockedVersion: '1', + sharedVariableName: 'org.apache.lucene:*', + fileReplacePosition: 39, + depType: 'dependencies', + }, + { + managerData: { + fileReplacePosition: 113, + packageFile: 'versions.props', + }, + depName: 'org.apache.foo-bar:a', + currentValue: '5', + lockedVersion: '1', + sharedVariableName: 'org.apache.foo*:*', + fileReplacePosition: 113, + depType: 'dependencies', + }, + ], + }, + ]); + }); }); }); diff --git a/lib/modules/manager/gradle/extract/catalog.spec.ts b/lib/modules/manager/gradle/extract/catalog.spec.ts index f1dc53281634a545be12c6bc27747a9d1fa46578..6f470a04b77c07f471fe201208effc2de4f86ebf 100644 --- a/lib/modules/manager/gradle/extract/catalog.spec.ts +++ b/lib/modules/manager/gradle/extract/catalog.spec.ts @@ -50,7 +50,7 @@ describe('modules/manager/gradle/extract/catalog', () => { }, { depName: 'com.squareup.retrofit2:retrofit', - groupName: 'retro.fit', + sharedVariableName: 'retro.fit', currentValue: '2.8.2', managerData: { fileReplacePosition: 42, @@ -94,7 +94,7 @@ describe('modules/manager/gradle/extract/catalog', () => { depName: 'org.jetbrains.kotlin.plugin.serialization', depType: 'plugin', currentValue: '1.5.21', - groupName: 'kotlin', + sharedVariableName: 'kotlin', packageName: 'org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin', managerData: { @@ -133,7 +133,7 @@ describe('modules/manager/gradle/extract/catalog', () => { expect(res).toStrictEqual([ { depName: 'io.gitlab.arturbosch.detekt:detekt-formatting', - groupName: 'detekt', + sharedVariableName: 'detekt', currentValue: '1.18.1', managerData: { fileReplacePosition: 21, @@ -150,7 +150,7 @@ describe('modules/manager/gradle/extract/catalog', () => { fileReplacePosition: 21, packageFile: 'gradle/libs.versions.toml', }, - groupName: 'detekt', + sharedVariableName: 'detekt', }, ]); }); @@ -173,7 +173,7 @@ describe('modules/manager/gradle/extract/catalog', () => { expect(res).toStrictEqual([ { depName: 'junit:junit', - groupName: 'junit', + sharedVariableName: 'junit', currentValue: '1.4.9', managerData: { fileReplacePosition: 124, @@ -182,7 +182,7 @@ describe('modules/manager/gradle/extract/catalog', () => { }, { depName: 'mocha-junit:mocha-junit', - groupName: 'mocha.junit.reporter', + sharedVariableName: 'mocha.junit.reporter', currentValue: '2.0.2', managerData: { fileReplacePosition: 82, diff --git a/lib/modules/manager/gradle/extract/catalog.ts b/lib/modules/manager/gradle/extract/catalog.ts index e4ed8d634266a685f0625eaee6a589e3f7b41126..36a21a5b80639e0cdfb7c8746594c62bdd4fa3d8 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<GradleManagerData> { 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.spec.ts b/lib/modules/manager/gradle/extract/consistent-versions-plugin.spec.ts index fdde721e725453eeb5c7129895f20fffbd9faa89..850031576ba663e1619265abf2df95853ec45873 100644 --- a/lib/modules/manager/gradle/extract/consistent-versions-plugin.spec.ts +++ b/lib/modules/manager/gradle/extract/consistent-versions-plugin.spec.ts @@ -136,7 +136,7 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => { depName: 'org.apache.lucene:a.c', currentValue: '2', lockedVersion: '1', - groupName: 'org.apache.lucene:a.*', + sharedVariableName: 'org.apache.lucene:a.*', depType: 'dependencies', }, { @@ -147,7 +147,7 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => { depName: 'org.apache.lucene:a.d', currentValue: '2', lockedVersion: '1', - groupName: 'org.apache.lucene:a.*', + sharedVariableName: 'org.apache.lucene:a.*', depType: 'dependencies', }, { @@ -158,7 +158,7 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => { depName: 'org.apache.lucene:d', currentValue: '3', lockedVersion: '1', - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', depType: 'dependencies', }, { @@ -169,7 +169,7 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => { depName: 'org.apache.lucene:e.f', currentValue: '3', lockedVersion: '1', - groupName: 'org.apache.lucene:*', + sharedVariableName: 'org.apache.lucene:*', depType: 'dependencies', }, { @@ -180,7 +180,7 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => { depName: 'org.apache.foo-bar:a', currentValue: '5', lockedVersion: '1', - groupName: 'org.apache.foo*:*', + sharedVariableName: 'org.apache.foo*:*', depType: 'dependencies', }, ]); diff --git a/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts b/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts index 4feeb3712088029a82eaac05d3b09c985de7b502..22ec356576adbee079e30d962f5e4fc40a38ab83 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<GradleManagerData>; 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 6e835a56d6be0039d201a4a7c9d93804bf5aa63f..037799c81c6e3b89c484ad4e7e8f0c6926e05e62 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} @@ -807,7 +811,7 @@ describe('modules/manager/gradle/parser', () => { { currentValue: '1.5.2.RELEASE', depName: 'org.springframework.boot:spring-boot-gradle-plugin', - groupName: 'springBootVersion', + sharedVariableName: 'springBootVersion', managerData: { fileReplacePosition: 53, packageFile: 'build.gradle', @@ -1039,7 +1043,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' }} @@ -1093,7 +1097,7 @@ describe('modules/manager/gradle/parser', () => { deps: [ { depName: 'org.slf4j:slf4j-api', - groupName: 'Versions.baz', + sharedVariableName: 'Versions.baz', currentValue: '1.2.3', }, { @@ -1102,17 +1106,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', }, ], @@ -1166,22 +1170,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', }, ], }); @@ -1218,7 +1222,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 4cb6fe719b1118220b0e894cd819ddf853b469d0..5aaba92f773cf728c645a9a32daf60ffcb94d9cf 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, @@ -197,7 +197,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, @@ -206,7 +206,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, @@ -247,7 +247,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, @@ -429,7 +429,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 4d0a77623d58108fcd77d8468037ed3a4c17b338..cd46e12ca1a1673e23e305d75100007c1cafb6d4 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 0839c2c7e20bb36ec181f86de2ca97dce6e26ed6..4286535ece0b47407695bb0b69949c67c9019bcd 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 53d474d9490a58dc2b610b4420b9f855e00b061e..147031d85458749af988af6597b8838d2d307bbb 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 76e3d765e03d4ef2ce30b96d6a1fe730acc024a0..867a2a5d964dcdea94d025b901ab4f6fa42b58c3 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 680b5f14cb025f93d3493d59119d8b139bd7daad..54ede6bd46fe680e278e799e8fa7a093a825008f 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 3efc9d99aea9fa251a024041e68932b0309f9902..f564c877d543a3ce1b698b5c6e8a3cd42420709e 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 ef06fe3911228c151b4d9d9b4828f726c048f0d6..939e31e25c1e8a62631b19ceebbb43ba1af57638 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 b22261c0a85162604575ba9b80b5c7e223358c00..413892c462cf833efd7aa2a722c0749d7a48c975 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 6c9d28db1b8a501856ce4647382d15ccd4313604..41c7e9dffac96c318d69deaa19bd11604c147f4f 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/nuget/__snapshots__/extract.spec.ts.snap b/lib/modules/manager/nuget/__snapshots__/extract.spec.ts.snap index a8d2ae43fc717d9bc6e884e877306352220934b3..60fcf38b3c7145e626809ae632d5af09a30df35e 100644 --- a/lib/modules/manager/nuget/__snapshots__/extract.spec.ts.snap +++ b/lib/modules/manager/nuget/__snapshots__/extract.spec.ts.snap @@ -134,14 +134,14 @@ exports[`modules/manager/nuget/extract extractPackageFile() extracts all depende "datasource": "nuget", "depName": "Autofac.Extensions.DependencyInjection", "depType": "nuget", - "groupName": "AutofacVersion", + "sharedVariableName": "AutofacVersion", }, { "currentValue": "4.5.0", "datasource": "nuget", "depName": "Autofac", "depType": "nuget", - "groupName": "AutofacVersion", + "sharedVariableName": "AutofacVersion", }, ] `; diff --git a/lib/modules/manager/nuget/extract.ts b/lib/modules/manager/nuget/extract.ts index 56e832df34ec72a6a156265663f444cb337151d4..3c9e6d8e9d768f2e060fd5ccde42e202fb44fc35 100644 --- a/lib/modules/manager/nuget/extract.ts +++ b/lib/modules/manager/nuget/extract.ts @@ -80,21 +80,21 @@ function extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] { dep.skipReason = 'invalid-version'; } - let groupName: string | undefined; + let sharedVariableName: string | undefined; currentValue = currentValue ?.trim() ?.replace(/^\$\((\w+)\)$/, (match, key) => { const val = vars.get(key); if (val) { - groupName = key; + sharedVariableName = key; return val; } return match; }); - if (groupName) { - dep.groupName = groupName; + if (sharedVariableName) { + dep.sharedVariableName = sharedVariableName; } currentValue = checkVersion diff --git a/lib/modules/manager/poetry/schema.ts b/lib/modules/manager/poetry/schema.ts index 6e650c21b2d0fc6f9df25b8a92db4e8bbf4f1bfa..eb4df77fca185850ca0d6f44541ebbfa21316df5 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 e369d665da0fc26f81f5bbfeddce3bd2588dc9d9..87d51705bf4989942789f1c4528a9d2abc1c1042 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 7410b282ae382c34384e0bc73e232451686dc142..03f3cbf232c2f79f53a134caf3fee815afe5d493 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 fd5a9173769dd07769d8872a094546b3b4065da3..80bfc399ee0acf813309a013a6184c3e85e44d9d 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 7fa394d4ebaa1135728631e824bce2822281cd87..6c93b44a19556af7a349e970a74ff00049a883a8 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -120,7 +120,7 @@ export interface PackageDependency<T = Record<string, any>> 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 a4b4dd5993954e202472422ed5d6ccaf72d32dcc..5feb61bb8e0e57a169b5bcfb45844f8c7c60939f 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 d151c0772b8c240e177478123fcfc7fd0aa36961..36f085dd1fe08d788c25245cd175c30d8306b135 100644 --- a/lib/workers/repository/updates/branch-name.ts +++ b/lib/workers/repository/updates/branch-name.ts @@ -57,6 +57,12 @@ 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; + } if (update.groupName) { update.groupName = template.compile(update.groupName, update); logger.trace('Using group branchName template');