Sort allow-plugins and preferred-install when feasible#980
Merged
localheinz merged 1 commit intoergebnis:mainfrom Oct 10, 2023
Merged
Sort allow-plugins and preferred-install when feasible#980localheinz merged 1 commit intoergebnis:mainfrom
allow-plugins and preferred-install when feasible#980localheinz merged 1 commit intoergebnis:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #980 +/- ##
============================================
+ Coverage 97.52% 97.62% +0.09%
- Complexity 166 173 +7
============================================
Files 30 30
Lines 728 758 +30
============================================
+ Hits 710 740 +30
Misses 18 18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
3701c8c to
342bbae
Compare
342bbae to
9d8f548
Compare
allow-plugins and preferred-install when feasible
9d8f548 to
45fc200
Compare
No sorting will be applied if there are wildcards in the middle of strings.
45fc200 to
31e7029
Compare
localheinz
approved these changes
Oct 10, 2023
Member
|
Thank you, @fredden! |
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.
Following on from the discussion in #775 (comment), this pull request re-adds sorting of
allow-pluginsandpreferred-install, but takes into account the difficult case of a wildcard in the middle of a package name.This pull request
config.allow-pluginsincomposer.jsonwhen there are no wildcards used.config.allow-pluginsincomposer.jsonwhen there are wildcards used, but only at the end of package names.config.allow-pluginsincomposer.jsonunsorted when there are wildcards used in the middle of a package name.config.preferred-installincomposer.jsonwhen there are no wildcards used.config.preferred-installincomposer.jsonwhen there are wildcards used, but only at the end of package names.config.preferred-installincomposer.jsonunsorted when there are wildcards used in the middle of a package name.Follows #775 (comment)
I considered only sorting the packages when there are no wildcards. This would make the code much more simple, and remove any chance of messing up the wildcard parsing process. I opted to sort the list whenever possible, including when wildcards are used, but kept the not-sorted behaviour when a wildcard is found part-way-through a package name.
Another approach that I considered was to remove entries which are unreachable (see the '.../IsUseful/No/' test fixtures). I decided to keep these as users may have added entries thinking that the list sorts the other way (last match, whereas it is actually first-match). Correcting this seems most useful to end users. They can then make their own decision if the entry should exist or not.