Skip to content

Commit

Permalink
create function normalizeVersionPointer
Browse files Browse the repository at this point in the history
Signed-off-by: Jinna C <jinnatim@gmail.com>
  • Loading branch information
cjtim committed May 4, 2023
1 parent 92970d8 commit 01975f1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 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,7 +83,7 @@ function extractVersion({
versionSubContent: string;
}): VersionExtract {
if (isVersionPointer(version)) {
const parsedVersion = version.ref.replace(regEx(/[._]/g), '-');
const parsedVersion = normalizeVersionPointer(version.ref);
// everything else is ignored
return extractLiteralVersion({
version: versions[parsedVersion],
Expand Down Expand Up @@ -206,7 +210,7 @@ function extractDependency({
};
}
const versionRef = isVersionPointer(descriptor.version)
? descriptor.version.ref.replace(regEx(/[._]/g), '-')
? normalizeVersionPointer(descriptor.version.ref)
: null;
if (isArtifactDescriptor(descriptor)) {
const { group, name } = descriptor;
Expand Down Expand Up @@ -285,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

0 comments on commit 01975f1

Please sign in to comment.