Add —only flag for files-pull, limiting scope#263
Conversation
Pull pipeline performance —
|
| Stage | PR | trunk | Δ | Status | Details |
|---|---|---|---|---|---|
playground-sqlite-db-pull |
9.30 s | 9.39 s | ⚪ -86 ms (-0.9%) | ✓ | condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected trunk: condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected |
playground-sqlite-db-apply |
3.81 s | 3.53 s | ⚪ +277 ms (+7.8%) | ✓ | condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified trunk: condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified |
| Total | 13.11 s | 12.92 s | ⚪ +190 ms (+1.5%) |
Numbers carry runner noise; treat single-run deltas as directional, not authoritative.
📈 Trunk performance history — commit-by-commit timeline.
There was a problem hiding this comment.
Pull request overview
This PR adds a --only SRC flag to the files-pull command, allowing users to limit file imports to specific folders/files (e.g., --only wp-content or --only wp-content/plugins,wp-content/themes). It builds on top of the --remap infrastructure from PR #262, reusing the WP-path resolution logic while adding scope-aware deletion in the diff reconciliation loop.
Changes:
- New
resolve_scope()andin_scope()methods for resolving WP-layout paths to real source prefixes and checking membership, with detached-component expansion and prefix collapse. - Scope-guarded delete drains in
diff_indexes_and_build_fetch_list()so out-of-scope local files survive across scoped runs, andget_export_directories()returns scope prefixes directly when active. - Extraction of
detached_component_sources()as a shared helper (refactored fromresolve_remap), addition ofwp-config.phpto the component source paths, and CLI option registration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/reprint-importer/src/import.php |
Core implementation: $scope property, resolve_scope(), in_scope(), detached_component_sources() extraction, scoped download_remote_index/diff_indexes_and_build_fetch_list/get_export_directories, wp-config.php in component paths, CLI option definition |
tests/Import/OnlyScopeTest.php |
Unit tests for scope resolution, detached-component expansion, prefix collapse, and scoped enumeration |
tests/Import/OnlyScopedDiffTest.php |
Integration test verifying the diff loop preserves out-of-scope files while deleting in-scope orphans |
tests/Import/OnlyCliParseTest.php |
CLI parsing test confirming --only is recognized in both --only=VAL and --only VAL forms |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1bcc628 to
a25e021
Compare
The new flag allows for specifying which folders should be imported, allowing you to limit an import: --only :wp-content: --only :wp-plugins:,:wp-content:/themes
a25e021 to
6dde0bb
Compare
6dde0bb to
e9914ca
Compare
|
Gonna go ahead and merge this in so we can get everything wired up. If there's any feedback, can address in a follow-up PR. |
## What it does #263 introduced an `--only` argument to filter which files are getting pulled. This PR changes how multiple paths are passed to reprint. **Before:** `--only :wp-content:/plugins,:wp-uploads:/2025` **After:** `--only :wp-content:/plugins --only :wp-uploads:/2025` ## Rationale `,` is a valid directory-name byte. Using it for splitting leaves no way of filtering directory names containing a comma. ## Implementation `--only` stays a `value-or-next` option, but is marked `repeatable`. `_cli_store()` appends repeatable values to an array, and `ImportClient::run()` passes that array through to path-prefix resolution. The focused CLI parser tests cover both invariants: - repeated `--only` values are preserved - commas inside one `--only` path are not split ## Testing instructions ```bash php -l packages/reprint-importer/src/import.php php -l tests/Import/OnlyCliParseTest.php phpunit --configuration tests/phpunit.xml --filter 'OnlyCliParse' ```
The PR adds a new
--only SOURCEflag, allowing for specifying which folders should be imported, allowing you to limit an import::token:convention as--remap(or a raw absolute path). Each token auto-resolves to the real source location from preflight.:wp-content:,:wp-plugins:,:wp-mu-plugins:,:wp-uploads:,:abspath:. Can append a sub-path after any token (e.g.:wp-content:/themes).Testing
You'll need a source site with the reprint exporter installed.
Confirm the scope was respected. Try again with
--only :wp-plugins:, and note that the prev-imported themes/uploads aren't deleted.