Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c3eb4ca
Merge pull request #1 from actions/main
mahabaleshwars Mar 4, 2024
7abdf1c
added support for tool version file
mahabaleshwars Mar 4, 2024
a7f2ec4
testing with one regex
mahabaleshwars Mar 4, 2024
12fa539
working regex
mahabaleshwars Mar 4, 2024
3ac7f4d
Checked for the file extension
mahabaleshwars Mar 4, 2024
7ac1739
added e2e checks for tool version
mahabaleshwars Mar 4, 2024
c2eed4c
removed error warning
mahabaleshwars Mar 5, 2024
d6dce30
updated regex to support early version
mahabaleshwars Mar 7, 2024
15bd552
updated regex for early version support
mahabaleshwars Mar 7, 2024
091c706
updated regex for early version
mahabaleshwars Mar 7, 2024
23f648d
updated regex to accept early versions
mahabaleshwars Mar 8, 2024
108d337
added coreinfo to analyze
mahabaleshwars Mar 8, 2024
600bab6
updated the regex
mahabaleshwars Mar 8, 2024
7e1d245
updated regex
mahabaleshwars Mar 8, 2024
7c2ba30
new regex for early version
mahabaleshwars Mar 8, 2024
4963182
updated regex to match the new version file format
mahabaleshwars Mar 8, 2024
5633ed7
new regex
mahabaleshwars Mar 8, 2024
0bd564a
changed the regex
mahabaleshwars Mar 8, 2024
dc07897
redex updated
mahabaleshwars Mar 8, 2024
ac5ac98
used java version regex
mahabaleshwars Mar 8, 2024
00ea4e3
regex updated
mahabaleshwars Mar 8, 2024
3a44440
regex modified
mahabaleshwars Mar 8, 2024
ae1e7f4
regex updated
mahabaleshwars Mar 8, 2024
4ef246e
regex updated
mahabaleshwars Mar 8, 2024
8c268be
regex updated
mahabaleshwars Mar 8, 2024
c5831e8
updated regex to support early versions
mahabaleshwars Mar 8, 2024
0d65cda
Regex updated to support all java versions
mahabaleshwars Mar 8, 2024
4253d87
Documentation updated to add tool version description
mahabaleshwars Mar 11, 2024
33cfd28
Documentation updated for the tool version file
mahabaleshwars Mar 12, 2024
b71bea4
update the advanced doc and readme file to specify tool version changes
mahabaleshwars Mar 12, 2024
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
testing with one regex
  • Loading branch information
mahabaleshwars committed Mar 4, 2024
commit a7f2ec40007d79e424f0b70efc555859d03ba96f
13 changes: 6 additions & 7 deletions dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87889,13 +87889,12 @@ function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function getVersionFromFileContent(content, distributionName, versionFile) {
var _a, _b, _c, _d, _e;
let javaVersionRegExp;
if (versionFile == '.tool-versions') {
javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
const javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
// if (versionFile == '.tool-versions') {
// javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
// } else {
// javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
// }
const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
: '';
Expand Down
13 changes: 6 additions & 7 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125263,13 +125263,12 @@ function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function getVersionFromFileContent(content, distributionName, versionFile) {
var _a, _b, _c, _d, _e;
let javaVersionRegExp;
if (versionFile == '.tool-versions') {
javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
const javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
// if (versionFile == '.tool-versions') {
// javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
// } else {
Copy link

@rtyley rtyley Mar 14, 2024

Choose a reason for hiding this comment

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

Note that this regex will not accept full java versions commonly generated in asdf using latest - eg:

asdf local java latest:corretto-21

...will generate a file with this line:

java corretto-21.0.2.13.1

The regex doesn't recognise this, so setup-java will fail with this message:

Error: No supported version was found in file .tool-versions

If we play around with the regex, we can see that we have to edit the string down to java corretto-21.0.2 in order to get it to work:

image

// javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
// }
const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
: '';
Expand Down
13 changes: 7 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ export function getVersionFromFileContent(
distributionName: string,
versionFile: string
): string | null {
let javaVersionRegExp: RegExp;
if (versionFile == '.tool-versions') {
javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
} else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
const javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;

// if (versionFile == '.tool-versions') {
// javaVersionRegExp = /^java\s+(?:\S+-)?v?(?<version>[^\s]+)$/m;
// } else {
// javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
// }

const fileContent = content.match(javaVersionRegExp)?.groups?.version
? (content.match(javaVersionRegExp)?.groups?.version as string)
Expand Down