Skip to content

Treat leading tildes as absolute in FilePath string decoding - #1

Open
shindgew wants to merge 1 commit into
apple:mainfrom
shindgew:fix/filepath-tilde-absolute
Open

shindgew wants to merge 1 commit into
apple:mainfrom
shindgew:fix/filepath-tilde-absolute

Conversation

@shindgew

@shindgew shindgew commented Sep 17, 2026

Copy link
Copy Markdown

Type of change

  • Bug fix
  • xcprojformatter (CLI) change
  • Documentation update
  • Test addition
  • Other (describe below)

⚠️ This project does not accept pull requests for new schema fields/types or major new features.
If you are proposing something beyond a bug fix, CLI change, or documentation/test update, open a
Feature request
first and wait for feedback before writing code.


Summary

FilePath.init(base:path:) treats a leading ~ as absolute, matching Xcode’s tilde expansion
but FilePath.init(stringRepresentation:) only looked for /

That disagreement made paths like ~/project/file.swift decode as .group and then throw Base disagrees with absoluteness of path. The same failure hit JSON decoding, round-trips of absolute tilde paths, and FilePath string literals (which use try!).

Related issue

N/A

Changes

  • Infer .absolute from a leading ~ in FilePath.init(stringRepresentation:), matching init(base:path:).
  • Add round-trip coverage for ~, ~/…, and ~user/….
  • Keep generated relative test paths from using a leading ~, which init(base:path:) already rejects.
  • 🤔 2 typos found by AI

Testing

  • Existing tests pass (swift test)
  • New tests added for new functionality
  • Tested manually: [describe steps]

Checklist

  • I have read CONTRIBUTING.md
  • My change is in scope (see CONTRIBUTING.md)
  • Code follows the project's style guidelines
  • I have reviewed my own code and can explain all changes in detail
  • Documentation updated where applicable

@shindgew
shindgew marked this pull request as ready for review September 17, 2026 09:01
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.

1 participant