-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix: normalize Windows paths in ModuleId constructors #1744
Conversation
概述演练此次更改主要修改了 变更
针对链接问题的评估
可能相关的 PR
诗歌
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis pull request addresses the issue of normalizing Windows paths in the Changes
|
@@ -282,7 +282,9 @@ impl PartialOrd for ModuleId { | |||
impl ModuleId { | |||
// we use absolute path as module id now | |||
pub fn new(id: String) -> Self { | |||
Self { id } | |||
Self { | |||
id: win_path(id.as_str()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the win_path
function correctly handles all edge cases for path normalization, especially for paths that may contain special characters or invalid sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/mako/src/module.rs (1)
324-324
: 建议优化 PathBuf 转换链!当前实现使用了多次字符串转换:
to_string_lossy().to_string().as_str()
。建议简化转换链以提高效率。- id: win_path(path.to_string_lossy().to_string().as_str()), + id: win_path(path.to_string_lossy().as_ref()),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/mako/src/module.rs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: stable - i686-pc-windows-msvc - node@20
- GitHub Check: stable - x86_64-pc-windows-msvc - node@20
- GitHub Check: Clippy
- GitHub Check: Mako Build (macos-latest)
- GitHub Check: stable - aarch64-unknown-linux-musl - node@20
- GitHub Check: stable - aarch64-unknown-linux-gnu - node@20
- GitHub Check: Cargo Test
- GitHub Check: stable - x86_64-unknown-linux-musl - node@20
- GitHub Check: Code Coverage
- GitHub Check: stable - x86_64-unknown-linux-gnu - node@20
- GitHub Check: Mako Build (ubuntu-latest)
- GitHub Check: stable - aarch64-apple-darwin - node@20
- GitHub Check: stable - x86_64-apple-darwin - node@20
🔇 Additional comments (3)
crates/mako/src/module.rs (3)
285-287
: 路径规范化实现正确!构造函数中正确使用了
win_path
函数来规范化路径,实现符合预期。
309-311
: String 转换实现保持一致性!
From<String>
实现与构造函数保持一致,同样使用win_path
进行路径规范化,很好!
317-317
: &str 转换实现简洁有效!
From<&str>
实现采用了更简洁的写法,同时保持了路径规范化的一致性。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1744 +/- ##
=======================================
Coverage 54.80% 54.81%
=======================================
Files 180 180
Lines 18079 18081 +2
=======================================
+ Hits 9909 9911 +2
Misses 8170 8170 ☔ View full report in Codecov by Sentry. |
Close #1668
Summary by CodeRabbit
ModuleId
结构体的 ID 处理方式,现在使用win_path
函数对 ID 进行标准化处理。String
、&str
、PathBuf
)创建ModuleId
实例的方法,确保 ID 格式一致性。