Refactor: Deduplicate normalize_file_path and to_epoch_ms in export script (closes #46)#51
Conversation
…e file path util function
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR imports ChangesPath Normalization Deduplication and Testing
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_normalize_file_path.py`:
- Around line 38-42: The test_space_decoded currently expects mixed-case "My
Documents" on non-Windows but lowercased on Windows, which is inconsistent with
other Windows-drive normalization tests; update test_space_decoded to always
expect the lowercased form for the Windows-drive URI case by asserting that the
returned path contains "my documents" (and still assertNotIn("%20")), so the
expectation matches normalize_file_path behavior for "file:///C:/..." inputs and
aligns with the other Windows-drive tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3977d42e-d03a-4ed2-9fa3-5cf0189f866e
📒 Files selected for processing (2)
scripts/export.pytests/test_normalize_file_path.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_normalize_file_path.py`:
- Around line 80-84: The test test_file_uri_with_windows_drive currently accepts
either lowercase or uppercase drive letters but the normalization is documented
and other tests expect lowercase; update the assertion in
test_file_uri_with_windows_drive to require a lowercase drive prefix by
asserting out.startswith("c:") (or otherwise enforce out[0].islower() for the
drive letter) so the test fails if normalize_file_path stops lowercasing drive
letters; reference normalize_file_path and the test_file_uri_with_windows_drive
function when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3c1a6a08-5ed1-40af-8523-e92774802105
📒 Files selected for processing (1)
tests/test_normalize_file_path.py
Closes #46
Problem
scripts/export.pymaintained private copies ofnormalize_file_pathandto_epoch_msthat already existed inutils/path_helpers.py. The twonormalize_file_pathcopies had diverged: the export copy was missing the non-Windows cross-platform branch that handles Windows-style drive paths (D:/...,D:\...) on Linux/macOS — meaning cross-platform reads of Cursor's Windows workspaceStorage could produce inconsistent path keys depending on which code path was used.Changes
scripts/export.pynormalize_file_path(~13 lines) andto_epoch_ms(~22 lines)utils.path_helpersimport to include both functions alongside the existingget_workspace_folder_pathsaliastests/test_normalize_file_path.py(new)normalize_file_path, 9to_epoch_ms; 2 skip on win32 for POSIX passthrough only) covering the shared implementation:file:///andfile://URI stripping%20(space),%23(#),%3A(colon in URI-style prefix)Notes
utils/path_helpers.pyis a strict superset of the old export copy — it adds the non-Windows^[a-zA-Z]:[/\\]branch for Windows-style paths on Linux/macOS, which the export copy lacked.sys.path.insertblock inscripts/export.pyis intentionally left in place; removing it is part of the larger export-script-to-service-layer refactor (issue Add an optional parameter to disable rendering/exporting sensitive projects/chats #1).samples/example_chat_export.mdquotes the old function definitions as documentation; not touched.Verification
Summary by CodeRabbit
Refactor
Tests