Skip to content

Conversation

@vvreutskiy
Copy link

@vvreutskiy vvreutskiy commented Jan 21, 2026

Fixes #818

Problem:
Windows project names were incorrectly shortened from C--src--delete--ansible to just C, losing the actual project name.

Solution:
Added proper handling for Windows-style paths in two formats:

  • Direct paths: C:\work\projectproject
  • Escaped paths: C--src--data--projectproject

Both cases now extract the last segment as the project name, matching the behavior for Unix-style paths.

Tests:
Added test cases covering both Windows path formats in arbitrary directories.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced project name extraction and normalization from Windows-style file paths, including backslash-separated paths and double-dash segment handling
    • Improved compatibility for Windows directory paths to ensure consistent project name formatting across different path formats
  • Tests

    • Expanded test suite with comprehensive coverage for Windows path scenarios and directory structure variations

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

This change fixes Windows path handling in project name parsing. The implementation adds logic to normalize Windows-style absolute paths (with backslashes) and double-dash segments to correctly extract project names, preventing malformed outputs like single letters or dash-separated paths. Tests are added for these scenarios.

Changes

Cohort / File(s) Change Summary
Windows path handling and project name parsing
apps/ccusage/src/_project-names.ts
Added branches to parseProjectName function to handle Windows absolute paths (backslash-separated) by extracting the last segment and joining with '-'. Added handling for double-dash segments (split on -- and keep last segment). Extended test coverage with C:\Users... style paths and arbitrary directories to verify formatProjectName returns expected results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • ryoppippi

Poem

🐰 Hops with delight

Windows paths no longer break,
Backslashes now the right way take!
Project names shine bright and clean,
The finest parsing ever seen! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: improving project name handling on Windows, which directly addresses the core issue being resolved.
Linked Issues check ✅ Passed The code changes address the requirements from issue #818 by handling both Windows backslash paths and escaped double-dash paths to extract correct project names.
Out of Scope Changes check ✅ Passed All changes are focused on Windows path handling for project name extraction, directly aligned with the objectives outlined in issue #818.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

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.

[Bug] Invalid project names in windows

1 participant