Skip to content
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

Allow omitting patch in .ruby-version #2004

Merged
merged 1 commit into from May 2, 2024

Conversation

vinistock
Copy link
Member

Motivation

Closes #1969

Allow omitting the patch part of the version in the .ruby-version file. This is being formalized as part of the specification being discussed by rubygems, so we need to support it as well.

Implementation

I split the two behaviours in separate methods. When the patch is omitted, we need to list all available directories, sort them descending and then try to find one that matches the version.

Automated Tests

Added a test.

@vinistock vinistock added enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes labels May 2, 2024
@vinistock vinistock self-assigned this May 2, 2024
@vinistock vinistock requested a review from a team as a code owner May 2, 2024 17:47
@vinistock vinistock requested review from andyw8 and st0012 May 2, 2024 17:47
@@ -99,46 +138,51 @@ export class Chruby extends VersionManager {
private async discoverRubyVersion(): Promise<RubyVersion> {
let uri = this.bundleUri;
const root = path.parse(uri.fsPath).root;
let version: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed that we were unintentionally catching our custom error for invalid .ruby-version files on the same catch as the one intended for non-existing files.

That's incorrect. When we find a .ruby-version file, but the contents are invalid, we want to raise and not continue going up the directories.

vscode/src/ruby/chruby.ts Outdated Show resolved Hide resolved
vscode/src/test/suite/ruby/chruby.test.ts Show resolved Hide resolved
@vinistock vinistock force-pushed the vs/allow_omitting_patch_for_chruby branch from 8dce0be to 07bb07a Compare May 2, 2024 20:06
@vinistock vinistock requested a review from st0012 May 2, 2024 20:16
@vinistock vinistock merged commit 2a7bc10 into main May 2, 2024
39 checks passed
@vinistock vinistock deleted the vs/allow_omitting_patch_for_chruby branch May 2, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode extension + chruby custom paths via RUBIES = cannot find installation directory for Ruby
3 participants