Repository navigation
Add opt-in .distignore exclusions - #1560
Open
jakaria-istauk wants to merge 3 commits into
Open
jakaria-istauk wants to merge 3 commits into
jakaria-istauk wants to merge 3 commits into
Conversation
Parses a plugin's .distignore with .gitignore semantics, as wp dist-archive does, and resolves it into literal exclusions anchored to the plugin root, so they are matched like .pcpignore entries. Opt-in only; nothing applies it yet.
Adds an "Exclude files listed in .distignore" checkbox under Custom Exclusions. It is shown only when the selected plugin has a .distignore file and is off by default.
Brings the WP-CLI command to parity with the Admin option, with docs and a Behat scenario.
Contributor
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
1 of 2 tasks
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.
What?
Closes #1559
Refs #1159
Adds an opt-in, off-by-default option to leave out the files and directories a plugin's
.distignorelists, the same fileswp dist-archivekeeps out of the production zip:.distignorefile.wp plugin check <plugin> --use-distignore.It works the same way as the
.pcpignoreoption from #1460, and reuses its exclusion code.Why?
Running Plugin Check on a development checkout reports problems in files that never ship, such as test suites, build scripts, CI configuration, dotfiles and local build folders, so the real findings get lost.
.pcpignore(#1460) fixed this, but a plugin that builds its zip withwp dist-archivealready lists exactly those paths in.distignore. Without this option it has to copy them into.pcpignore, and the two files drift: a new dev folder added to only one of them is either scanned again or shipped without being checked.This PR lets the scan use the list the plugin already keeps, with the same safety rules already accepted for
.pcpignore:.distignoreunless asked. The checkbox is unchecked by default and only appears when the file exists, and the CLI flag defaults to off. So the WordPress.org scanner, which never passes the option, still inspects every file. This follows the requirement from the Implement includes, config file support & .distignore parsing (#1108, #1159) #1181 review that plugin authors must not be able to change the scanner's behaviour..gitignorerules, aswp dist-archivedoes. The scan leaves out exactly what the zip leaves out, no more and no less. That answers the "false sense of safety" concern from Feature, add support for .distignore #692 as far as a local option can.How?
Dist_Ignore_Utility(includes/Utilities/):.distignorewith.gitignorerules: a pattern containing a slash (other than a trailing one) is anchored to the plugin root, a pattern without one matches at any depth, a trailing/means directory only,*and?don't match/,**matches any number of directories, and a leading!re-includes a path.vendor,node_modules, ...) aren't walked either..pcpignoreentries, the existingIgnore_Matcherand PHPCS ignore patterns apply it unchanged, with the root anchoring the Add opt-in .pcpignore exclusions #1460 review asked for..pcpignore. The output is sorted, so it doesn't depend on filesystem order.data-has-distignore. The JS shows the checkbox only for those and unchecks it when hidden.Admin_AJAX::run_checks()reads the newuse-distignoreflag (any warning is returned asdistignore_warning, likepcpignore_warning).--use-distignoreonPlugin_Check_Command, which prints any warning throughWP_CLI::warning(). It's documented indocs/CLI.md.The
.pcpignoreand.distignoreoptions can be combined, since each only adds entries to the existingwp_plugin_check_ignore_directories/wp_plugin_check_ignore_filesfilters.Commits:
Add utility to resolve .distignore exclusions: the utility, PHPUnit tests and thetest-plugin-distignorefixtureAdd a .distignore option to the Admin scannerAdd --use-distignore to the plugin check command: CLI, Behat scenario and docsTesting Instructions
Admin
.distignoreto a test plugin, for example:<?php echo $_GET['x'];) inbin/and inincludes/tests/..distignore. The option disappears.bin/andincludes/tests/are reported. Check it again with the box checked: neither is reported, and shipped files still are.CLI
wp plugin check <plugin>reports files inbin/andincludes/tests/.wp plugin check <plugin> --use-distignoredoesn't report them.Automated:
Dist_Ignore_Utility_Testscovers anchored and any-depth patterns,**,!negation, a missing file, single-file plugins, and a full check run before and after applying the exclusions. The new Behat scenarioApply .distignore exclusions only when requestedcovers the CLI flag. The full suite passes on this branch on my fork, across PHP 7.4–8.4 and WP 6.3–trunk (checks). The only red step there is the Codecov upload, which fails on forks for lack of a token.AI Usage Disclosure
If AI tools were used, please describe how they were used:
I used Claude Code to help write the code, tests and this description. I reviewed every change, tested it by hand in the Admin UI and the CLI, and ran the full test suite.
Screenshots or screencast
.distignore(option hidden)If you'd rather ship only the CLI flag, or prefer a different label or position for the checkbox, I'm happy to adjust.