Skip to content

[Fixes #716] deal with multiple versions in .tool-versions #717

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

jtannas
Copy link
Contributor

@jtannas jtannas commented Mar 4, 2025

See #716 for explanation

Tested on one of my projects: https://github.com/jtannas/katachi/actions/runs/13660430691/job/38190080032?pr=19

While it might be cool for it to attempt each ruby version in order (aka. mimic ASDF parsing) or to treat multiple .tool-versions entries as a matrix, that's way beyond what I need and am comfortable tackling as a first PR.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@jtannas jtannas force-pushed the issue-716-multiple-tool-versions branch from 7bd137f to e6e23c7 Compare March 4, 2025 18:22
@jtannas jtannas marked this pull request as ready for review March 4, 2025 18:54
@@ -130,7 +130,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
rubyVersion = rubyLine.split(/\s/)[1]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rubyVersion = rubyLine.split(/\s/)[1]
rubyVersion = rubyLine.match(/^ruby\s+(\S+)/)[1]

would be another way but what you did seems fine too

@eregon eregon merged commit 277ba2a into ruby:master Mar 5, 2025
1 check passed
@eregon
Copy link
Member

eregon commented Mar 5, 2025

While it might be cool for it to attempt each ruby version in order (aka. mimic ASDF parsing)

I agree, that doesn't seem worth the complexity, at least not without a good use case.

or to treat multiple .tool-versions entries as a matrix, that's way beyond what I need and am comfortable tackling as a first PR.

Regarding treating as a matrix that's impossible, AFAIK an action cannot influence the matrix (at least in the same job).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support .tool-versions files with multiple versions
2 participants