-
-
Notifications
You must be signed in to change notification settings - Fork 405
Add support for :(optional) prefix for path configuration values
#2283
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
Conversation
:(optional) prefix for path configuration values
…ig-value It's breaking because it adds the `optional` field to the `Path` type. Co-authored-by: Byron <[email protected]>
3df2fbb to
c72ea8b
Compare
| let is_optional = path.is_optional; | ||
| let res = path.interpolate(ctx); | ||
| if is_optional { | ||
| if let Ok(path) = &res { | ||
| // As opposed to Git, for a lack of the right error variant, we ignore everything that can't | ||
| // be stat'ed, instead of just checking if it doesn't exist via error code. | ||
| if path.metadata().is_err() { | ||
| return None; | ||
| } | ||
| } | ||
| } | ||
| Some(res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Write tests for accessing optional configuration paths, as added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 4 comprehensive tests for accessing optional configuration paths in commit 4ffcaa4:
optional_path_with_existing_file_is_returned- verifies optional paths with existing files return Some(Ok(path))optional_path_with_missing_file_returns_none- verifies optional paths with missing files return Nonerequired_path_with_existing_file_is_returned- verifies required paths with existing files work correctlyrequired_path_with_missing_file_returns_some_in_lenient_mode- verifies lenient mode behavior
The tests use the trusted_path() method on config snapshots and validate the :(optional) prefix behavior through the trusted_file_path() function. Test fixtures are generated with absolute paths using the make_config_repos.sh script.
…ConfigSnapshot::trusted_path()`. Optional, but non-existing paths are now returned as `None`.
c72ea8b to
580bee9
Compare
|
Great basis to build on top of! |
Tests for optional path configuration
Added 4 comprehensive tests for accessing optional configuration paths:
✅ optional_path_with_existing_file_is_returned - Verifies that optional paths with existing files return Some(Ok(path))
✅ optional_path_with_missing_file_returns_none - Verifies that optional paths with missing files return None (not an error)
✅ required_path_with_existing_file_is_returned - Verifies that required paths with existing files return Some(Ok(path))
✅ required_path_with_missing_file_returns_some_in_lenient_mode - Verifies that required paths with missing files in lenient mode still return Some(Ok(path))
The tests use the
trusted_path()API on config snapshots and verify the behavior of the:(optional)prefix implementation intrusted_file_path()function.Test fixtures created with absolute paths to ensure proper file existence checking.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.