Skip to content

Conversation

@ronnnnn
Copy link
Contributor

@ronnnnn ronnnnn commented Oct 15, 2025

Overview

I had a mistake on #94.
We can't find bun's version correctly when .tool-versions have other versions begin "bun".

Reproduce steps

In .tool-versions:

bundler 1.0.0
bun     1.0.0

Regex check

https://regex101.com/r/2aCusB/4

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Updated regex pattern in src/utils.ts for parsing '.tool-versions' file. Changed bun version pattern to use negative lookahead preventing letter continuation, and requires non-whitespace version tokens instead of optional content.

Changes

Cohort / File(s) Summary
Version parsing regex update
src/utils.ts
Modified bun version pattern in FILE_VERSION_READERS: added negative lookahead (?![a-zA-Z]) to prevent matching "bun" followed by letters, changed version capture from .*? to \S+ to require non-empty, non-space tokens

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: .tool-versions regex' accurately summarizes the main change: fixing a regex pattern for .tool-versions file parsing to handle the bun version detection issue.
Description check ✅ Passed The description is clearly related to the changeset, explaining the bug introduced in #94 where bun's version detection fails when tool names beginning with 'bun' are present, with reproduction steps and a regex test link.

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a961131 and 46fef78.

⛔ Files ignored due to path filters (1)
  • dist/setup/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/utils.ts
🔇 Additional comments (1)
src/utils.ts (1)

78-78: LGTM! The negative lookahead correctly fixes the bundler false-match bug.

The regex successfully prevents matching tool names like "bundler" while correctly extracting the bun version. The implementation correctly handles:

  • Prevents false matches: "bundler 1.0.0" fails at (?![a-zA-Z])
  • Standard format: "bun 1.0.0" matches with version "1.0.0" ✓
  • Compact format: "bun1.0.0" matches with version "1.0.0" ✓ (as mentioned in your commit message)
  • All version specifiers: \S+ supports "latest", "canary", semver, pre-releases, etc. ✓

Note on design choice: Using \s* (zero or more spaces) instead of \s+ (one or more) makes the parser more permissive than the standard .tool-versions format, but this aligns with your stated intent to support compact entries like "bun1.1.0". The negative lookahead elegantly solves the core issue while maintaining this flexibility.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6356405 and e5ed3e1.

⛔ Files ignored due to path filters (1)
  • dist/setup/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/utils.ts (1 hunks)

Copy link
Collaborator

@xhyrom xhyrom left a comment

Choose a reason for hiding this comment

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

LGTM

@ronnnnn ronnnnn requested a review from xhyrom October 31, 2025 00:29
@ronnnnn
Copy link
Contributor Author

ronnnnn commented Oct 31, 2025

@xhyrom
Thank you for your review. I fixed the CI failure.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e5ed3e1 and b08cdef.

⛔ Files ignored due to path filters (1)
  • dist/setup/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/utils.ts (1 hunks)

@ronnnnn ronnnnn force-pushed the fix-tool-versions-match branch from b08cdef to a961131 Compare October 31, 2025 00:40
file: .tool-versions
run: echo "bun 1.1.0" > .tool-versions

- name: .tool-versions (bun1.1.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this format is not supported on asdf

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should continue supporting this, even though it’s invalid, until the next major version so we don’t break semver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I've updated the regex to use negative lookahead (?![a-zA-Z]) which:

  • Excludes bundler and similar patterns (the original bug)
  • Maintains backward compatibility for bun1.1.0 format (no space)
  • Keeps support for the standard bun 1.1.0 format

This approach preserves semver compatibility as @xhyrom suggested.

file: .tool-versions
run: echo "bun 1.1.0" > .tool-versions

- name: .tool-versions (bun1.1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should continue supporting this, even though it’s invalid, until the next major version so we don’t break semver

… support

- Update regex to /^bun(?![a-zA-Z])\s*(?<version>\S+)$/m
- Restore test case for .tool-versions (bun1.1.0)
@ronnnnn ronnnnn requested a review from xhyrom January 7, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants