refactor: move more platform-specific code under sys#735
Merged
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Public API changes for crate: brush-coreRemoved itemsAdded itemsPerformance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
Test Results 3 files 23 suites 6m 48s ⏱️ Results for commit 618d01e. ♻️ This comment has been updated with latest results. |
d48c9ac to
5cf8050
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors platform-specific code to improve cross-platform consistency and maintainability. The changes abstract platform-specific functionality behind a unified interface, reducing conditional compilation directives throughout the codebase.
Key changes:
- Introduced platform-specific
commandsmodule with unified extension traits (CommandExt,ExitStatusExt,CommandFdInjectionExt,CommandFgControlExt) - Consolidated signal handling through
sys::signal::Signalabstraction - Replaced direct
uzersandnixusage withsys::usersabstraction - Added
PlatformErrortype to unify platform-specific error handling - Created
completionfeature flag inbrush-interactiveto gate completion functionality - Standardized platform conditionals to use
any(unix, windows)ordering consistently - Replaced
error::unimp()calls withNotSupportedOnThisPlatformerror variant - Removed
procfsdependency and cleaned up unused imports
Reviewed Changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| brush-shell/src/shell_factory.rs | Standardized platform conditionals order and added unused_variables allow for cross-platform compatibility |
| brush-shell/src/main.rs | Extracted terminal reset logic to function, added unused_imports allow, converted exit code cast to use From trait |
| brush-shell/Cargo.toml | Reordered platform conditionals for consistency |
| brush-interactive/src/lib.rs | Changed completion module gate from platform-specific to feature-based |
| brush-interactive/Cargo.toml | Added completion feature flag and made it a dependency of basic and reedline features |
| brush-core/src/wellknownvars.rs | Replaced platform-specific code with sys abstractions for UID/EUID/HOSTTYPE |
| brush-core/src/traps.rs | Abstracted signal handling through sys::signal::Signal |
| brush-core/src/sys/windows/users.rs | Added get_current_uid/gid functions, updated error handling to use NotSupportedOnThisPlatform |
| brush-core/src/sys/windows.rs | Added commands module and PlatformError type |
| brush-core/src/sys/wasm.rs | Added commands module and PlatformError type |
| brush-core/src/sys/unix/users.rs | Added get_current_uid/gid wrapper functions |
| brush-core/src/sys/unix/signal.rs | Exported nix::sys::signal::Signal |
| brush-core/src/sys/unix/fs.rs | Made MetadataExt public export instead of private use |
| brush-core/src/sys/unix/commands.rs | New module with Unix-specific command extension trait implementations |
| brush-core/src/sys/unix.rs | Added commands module and PlatformError type with From impl for nix::errno::Errno |
| brush-core/src/sys/stubs/users.rs | Added get_current_uid/gid, updated error handling |
| brush-core/src/sys/stubs/signal.rs | Added stub Signal enum with required methods |
| brush-core/src/sys/stubs/input.rs | Updated error handling to use NotSupportedOnThisPlatform |
| brush-core/src/sys/stubs/fs.rs | Renamed trait from StubMetadataExt to MetadataExt, updated error handling |
| brush-core/src/sys/stubs/commands.rs | New module with stub command extension trait implementations |
| brush-core/src/sys/stubs.rs | Added commands module |
| brush-core/src/sys/fs.rs | Removed conditional MetadataExt re-exports (now handled in platform modules) |
| brush-core/src/sys.rs | Added public exports for commands and PlatformError |
| brush-core/src/openfiles.rs | Removed top-level Unix imports, moved to function scope, removed unused as_raw_fd method |
| brush-core/src/lib.rs | Reordered module declarations (moved completion module down in list) |
| brush-core/src/interp.rs | Replaced Unix-specific imports with sys::commands::ExitStatusExt, moved AsFd import to function scope |
| brush-core/src/error.rs | Replaced platform-specific error variants with unified PlatformError variant, added NotSupportedOnThisPlatform variant |
| brush-core/src/commands.rs | Replaced inline platform-specific code with sys::commands trait methods |
| brush-core/Cargo.toml | Reordered platform conditionals, removed procfs dependency, added sync feature to wasm tokio |
| brush-builtins/src/read.rs | Converted cast to use From trait |
| brush-builtins/src/factory.rs | Added unused_imports allow for cross-platform compatibility |
| brush-builtins/Cargo.toml | Reordered platform conditionals |
| Cargo.lock | Removed procfs dependency |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.