Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(managers/gradle): allow dot annotation in version.ref #21820

Merged
merged 6 commits into from May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,5 +17,5 @@ kotest = [ "kotest-runner-junit5", "kotest-assertions-core-jvm" ]

[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
publish-on-central = { id = "org.danilopianini.publish-on-central", version.ref = "publish-on-central" }
publish-on-central = { id = "org.danilopianini.publish-on-central", version.ref = "publish.on.central" }
grgit = { id = "org.ajoberstar.grgit", version.unknown = "this will fail" }
Expand Up @@ -7,4 +7,4 @@ junit = "1.4.9"

[libraries]
junit-legacy = { module = "junit:junit", version.ref = "junit" }
mocha-junit = { module = "mocha-junit:mocha-junit", version.ref = "mocha-junit-reporter" }
mocha-junit = { module = "mocha-junit:mocha-junit", version.ref = "mocha.junit.reporter" }
13 changes: 9 additions & 4 deletions lib/modules/manager/gradle/extract/catalog.ts
Expand Up @@ -55,6 +55,10 @@ function isVersionPointer(
return hasKey('ref', obj);
}

function normalizeVersionPointer(versionPointer: string): string {
return versionPointer.replace(regEx(/[._]/g), '-');
}

interface VersionExtract {
currentValue?: string;
fileReplacePosition?: number;
Expand All @@ -79,12 +83,13 @@ function extractVersion({
versionSubContent: string;
}): VersionExtract {
if (isVersionPointer(version)) {
const parsedVersion = normalizeVersionPointer(version.ref);
// everything else is ignored
return extractLiteralVersion({
version: versions[version.ref],
version: versions[parsedVersion],
depStartIndex: versionStartIndex,
depSubContent: versionSubContent,
sectionKey: version.ref,
sectionKey: parsedVersion,
});
} else {
return extractLiteralVersion({
Expand Down Expand Up @@ -205,7 +210,7 @@ function extractDependency({
};
}
const versionRef = isVersionPointer(descriptor.version)
? descriptor.version.ref
? normalizeVersionPointer(descriptor.version.ref)
: null;
if (isArtifactDescriptor(descriptor)) {
const { group, name } = descriptor;
Expand Down Expand Up @@ -284,7 +289,7 @@ export function parseCatalog(
dependency.skipReason = skipReason;
}
if (isVersionPointer(version) && dependency.commitMessageTopic) {
dependency.groupName = version.ref;
dependency.groupName = normalizeVersionPointer(version.ref);
delete dependency.commitMessageTopic;
}

Expand Down