Skip to content

Rust extractors: Normalize drive letter paths with a trailing / #18770

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
Feb 13, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Feb 13, 2025

On #18767 I learned that root paths on Windows, like c:\, are currently normalized to C:, while the shared YAML extractor normalizes it as C:/. This PR aligns the behavior of the Rust-based extractors with the YAML extractor.

@hvitved hvitved added Rust Pull requests that update Rust code Ruby and removed Ruby Rust Pull requests that update Rust code labels Feb 13, 2025
@hvitved hvitved force-pushed the shared/windows-drive-letter-trap-id branch from a3c077c to 02fd23e Compare February 13, 2025 13:03
@hvitved hvitved changed the title Rust extractors: Canonicalize drive letter paths with a trailing / Rust extractors: Normalize drive letter paths with a trailing / Feb 13, 2025
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Feb 13, 2025
@hvitved hvitved marked this pull request as ready for review February 13, 2025 13:18
@Copilot Copilot AI review requested due to automatic review settings February 13, 2025 13:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR updates the path normalization function to ensure that drive letter paths ending at the root include a trailing slash (e.g., "C:/" instead of "C:").

  • Replaces the simple for loop with a peekable iterator to check if the current component is the final one.
  • Adds logic to push an empty string for the RootDir component when it is the last component, thereby achieving the desired trailing slash.

Changes

File Description
shared/tree-sitter-extractor/src/file_paths.rs Updated path normalization to add a trailing slash for root drive paths

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

shared/tree-sitter-extractor/src/file_paths.rs:30

  • Consider adding tests to verify that normalizing a drive letter root path correctly returns a trailing slash.
std::path::Component::RootDir => {

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

@hvitved hvitved merged commit bd9eb7d into github:main Feb 13, 2025
41 checks passed
@hvitved hvitved deleted the shared/windows-drive-letter-trap-id branch February 13, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants