Skip to content

Fix Windows path normalization for filename pattern matching#650

Open
factory-droid[bot] wants to merge 1 commit intomainfrom
droid/fix-windows-path-normalization
Open

Fix Windows path normalization for filename pattern matching#650
factory-droid[bot] wants to merge 1 commit intomainfrom
droid/fix-windows-path-normalization

Conversation

@factory-droid
Copy link

@factory-droid factory-droid bot commented Jun 26, 2025

Description

This PR fixes the issue where GritQL pattern checks involving filenames work differently on Windows versus macOS/Unix systems.

Changes

  1. Updated normalize_path_in_project in api.rs to normalize path separators by converting Windows-style backslashes (\) to Unix-style forward slashes (/)
  2. Changed the function's return type from &'a str to String since path separator normalization requires string allocation
  3. Added unit tests for Windows and mixed path separator normalization
  4. Added a new test fixture and integration test specifically for Windows path matching

Testing

  • Added unit tests directly in api.rs that verify Windows path separators (\) are converted to Unix style (/)
  • Created a new test fixture windows_path_match with sample patterns that specifically test path matching with different separator styles
  • Added an integration test that verifies patterns work correctly with both types of separators

Fixes #639

This PR was created with assistance from Droid.


Factory Session: https://app.factory.ai/sessions/Kcu0Kpw1Wei0WMYPiRJb

This change ensures consistent path normalization by:

1. Updating normalize_path_in_project to convert Windows-style backslashes
   to Unix-style forward slashes
2. Changing the return type from &str to String since normalization requires allocation
3. Adding unit tests for Windows/Unix path separator normalization
4. Adding integration tests to verify matching works with different separator styles

Fixes #639
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.

Grit checks checking filenames works differently on Windows

0 participants