Skip to content

Update Regex to Support All ASDF Versions for the supported distributions in tool-versions File #767

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
Check failures fix
  • Loading branch information
aparnajyothi-y committed Mar 20, 2025
commit 7872dcf07b2f1d448f70de42ea50726075db6dc0
2 changes: 1 addition & 1 deletion dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97075,7 +97075,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
/^(java\s+)(?:(?<distribution>\S+)-)?(?<version>\d+\.\d+\.\d+(\.\d+)?)(\+\d+(\.\d+)?)?(-[a-zA-Z0-9]+)?(\.LTS)?$/m;
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(\.\d+)?(-ea(\.\d+)?)?(\.LTS)?)$/m;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135080,7 +135080,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
/^(java\s+)(?:(?<distribution>\S+)-)?(?<version>\d+\.\d+\.\d+(\.\d+)?)(\+\d+(\.\d+)?)?(-[a-zA-Z0-9]+)?(\.LTS)?$/m;
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(\.\d+)?(-ea(\.\d+)?)?(\.LTS)?)$/m;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
Expand Down
3 changes: 2 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export function getVersionFromFileContent(
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
Copy link
Preview

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex regex pattern lacks documentation explaining its purpose and the various parts it matches. Add comments describing what each component captures.

Suggested change
javaVersionRegExp =
javaVersionRegExp =
/**
* Matches Java version strings in `.tool-versions` files.
* - ^java\s+: Matches lines starting with "java" followed by whitespace.
* - (?:\S*-)?: Optionally matches a non-whitespace string followed by a hyphen (e.g., "adopt-").
* - (?<version>\d+(?:\.\d+)*...): Captures the version number, which:
* - Starts with one or more digits (\d+).
* - May include additional dot-separated numeric components (e.g., "11.0.2").
* - May be followed by a suffix (e.g., "+", "_", ".", or "-") and:
* - openj9[-._]?\d[\w.-]*: Matches OpenJ9-specific versions (e.g., "openj9-0.24.0").
* - java\d+: Matches Java-specific identifiers (e.g., "java11").
* - jre[-_\w]*: Matches JRE-specific identifiers (e.g., "jre8").
* - OpenJDK\d+[\w_.-]*: Matches OpenJDK-specific identifiers (e.g., "OpenJDK11").
* - [a-z0-9]+: Matches other alphanumeric identifiers.
* - Flags:
* - i: Case-insensitive matching.
* - m: Multiline matching.
*/

Copilot uses AI. Check for mistakes.

/^(java\s+)(?:(?<distribution>\S+)-)?(?<version>\d+\.\d+\.\d+(\.\d+)?)(\+\d+(\.\d+)?)?(-[a-zA-Z0-9]+)?(\.LTS)?$/m;
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(\.\d+)?(-ea(\.\d+)?)?(\.LTS)?)$/m;

} else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy