Skip to content
New issue

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

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

Already on GitHub? # to your account

Minor change to Helidon version handling allowing snapshot versions #19320

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private HashMap<String, String> loadKnownHttpStatusMap() {
}

private void setHelidonVersion(String version) {
helidonVersion = VersionUtil.instance().chooseVersion(version);
helidonVersion = VersionUtil.instance().chooseVersionBestMatchOrSelf(version);
setParentVersion(helidonVersion);
helidonMajorVersion = VersionUtil.majorVersion(helidonVersion);
}
Expand Down Expand Up @@ -769,6 +769,30 @@ String chooseVersion(String requestedVersion) {
return chooseVersion(requestedVersion, versions);
}

/**
* Returns either the best match version of, if there is none, the requested version itself to allow references to
* unpublished releases such as snapshots.
*
* @param requestedVersion version to search for
* @return either the best match or, if none, the requested version itself
*/
String chooseVersionBestMatchOrSelf(String requestedVersion) {
return chooseVersionBestMatchOrSelf(requestedVersion, versions);
}

/**
* Returns either the best match version of, if there is none, the requested version itself to allow references to
* unpublished releases such as snapshots.
*
* @param requestedVersion version to search for
* @param candidateVersions releases to consider
* @return either the best match or, if none, the requested version itself
*/
String chooseVersionBestMatchOrSelf(String requestedVersion, List<String> candidateVersions) {
String bestMatch = chooseVersion(requestedVersion, candidateVersions);
return bestMatch != null ? bestMatch : requestedVersion;
}

/**
* Returns the version that is the "closest" match to the requested version expression from among the provided
* releases, where the expression expression is one of the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ void testVersionNotInDefaultListWithNoNetwork() {
}



@Test void checkUseOfUnpublishedRelease() {
assertThat(test.chooseVersionBestMatchOrSelf("4.0.11-SNAPSHOT",
List.of("4.0.10", "3.2.1", "3.2.0", "2.0.4", "1.2.3", "1.2.2", "1.1.0")))
.isEqualTo("4.0.11-SNAPSHOT");
}
}
Loading