Repository navigation
refactor(cli): make the whole migrate module Unix-only - #1153
Conversation
Gating `run` left every helper it called compiled but unreachable on Windows, and `-D warnings` makes each one a dead-code error: eleven of them, from `PostgresBackend` in the imports down to `open_existing_target`. The issue's own shape is the fix: `commands::migrate` is `#[cfg(unix)]`, and the other platform gets `migrate_unsupported.rs` at the same path, carrying the same `MigrateOptions` and a `run` that refuses. `main.rs` stays free of a `cfg` arm because both modules answer the same names. Verified by compiling the non-Unix arm on Linux: a scratch copy with the module cfgs swapped passes `cargo clippy -p nostream-cli --no-default-features --lib --bins -- -D warnings`, which is the check the Windows runner was failing.
🦋 Changeset detectedLatest commit: 32d278a The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
`migrate_unsupported.rs` is behind `#[cfg(not(unix))]`, so on Linux `cargo fmt --all` never visits it — and CI's `cargo fmt --all --check` runs on Linux, which is why the crate root's own listing decides what is formatted. Formatted by name instead.
`cargo fmt --all` formats the modules the crate root reaches, and the root's `cfg` picks one of the two `migrate` files per platform. Linux therefore never formats `migrate_unsupported.rs` and Windows never formats `migrate.rs`; a check on each platform covers both. This caught a wrapped signature in the unreachable file on the run before.
[Low impact] The PR appears safe to merge.
|
Coverage Report for CI Build 43802699298Coverage decreased (-0.006%) to 77.582%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Description
#1148gatedrunand every helper it could reach individually. Rust still type-checks a function nothing on the platform can call, so the Windows job it added then failed on eleven dead-code errors —PostgresBackendin the imports,records_progress,describe_source,is_url_with_host,without_credentials,probe_budget,no_store,store_present,check_resume_store,open_target,open_existing_target— all reachable only from the#[cfg(unix)] run().This takes the shape the issue asked for instead of more attributes:
crates/nostream-cli/src/commands/mod.rs—#[cfg(unix)] pub mod migrate;and, on the other platform,#[cfg(not(unix))] #[path = "migrate_unsupported.rs"] pub mod migrate;crates/nostream-cli/src/commands/migrate_unsupported.rs— the sameMigrateOptionsand arunthat writesmigrate pg-to-lmdb is unsupported on this platformand answers exit code 1.main.rsneeds nocfgarm: both modules answer the same names.migrate.rskeeps its internal gates (they are inert inside a Unix-only module) and loses the now-duplicate#[cfg(not(unix))] run.Related Issue
Closes #1121
How Has This Been Tested?
The non-Unix arm is compiled on Linux by swapping the two module attributes in a scratch copy, which is exactly the configuration the Windows runner builds:
The
windows-latestjob inchecks.yml, added by#1148, is the platform proof;migrate_cli_unsupported.rspins the refusal and that job runs it.Types of changes
Checklist: