Skip to content

Add a PatchPatcher plugin #677

@normanlolx

Description

@normanlolx

Verification

  • I have updated Composer to the most recent stable release (composer self-update)
  • I have updated Composer Patches to the most recent stable release (composer update cweagans/composer-patches)
  • I am using one of the supported PHP versions (8.0+)
  • I have searched existing issues and discussions for my idea.

Is your feature request related to a problem?

This is the default command that composer-patches v1 used to apply a patch:

patch '-p2' --no-backup-if-mismatch -d '/var/www/html/web/core' < '/mnt/ddev-global-cache/composer/patches/foobar.patch'

This is the default command that composer-patches v2 is using:

'git' -C '/var/www/html/web/core' apply --check --verbose -p2 '/mnt/ddev-global-cache/composer/patches/foobar.patch'

Problem with applying patches with git is: It doesn't have the built-in fuzzyness that patch has. For git the target file needs to look exactly as it's written in the .patch.

Now a lot of patches simply don't apply anymore with this message:

No available patcher was able to apply patch foobar.patch to drupal/core

Describe your proposed solution(s)

Similar to the existing GitPatcher plugin, add a PatchPatcher plugin.

This of course would contradict having it removed in v2 in the first place.

Which might make introducing another config option necessary to have the PatchPatcher disabled by default. To enable the PatchPatcher then people would need to enable it explicitly.

For example:

    "extra": {
        "composer-patches": {
            "include-patch-patcher": true
        }
    }

Describe alternatives

To make all patches getting applied with patch I can use the Freeform Patcher, but that would require changing all patches to the extended format, making the maintenance burden much higher.

Also not sure how that would work with nested patches coming from dependency's composer.json I can not control.

Additional context

Sample composer.json that works with v1 but does not work with v2:

composer.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, options, or other additions.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions