Skip to content

[Bug or new feature] Add support for local patch files and external patch file in dependencies #505

@michaelw85

Description

@michaelw85

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?

Yes, a patch will not be applied from one of the packages I'm installing (my own package).

Setup:

Root project
|_ dep 1 (required by root, containing patch)
|_ dep 2 (required by dep 1, should be patched by dep 1) 

issue 1
When dependency 1 uses an external patch file the patches are not detected and thus never applied.
gatherPatches only searches for the patches key.

issue 2
When switching to the patches configuration the patch will be found but when it's not an url but a local path e.g. patches/my-patch.patch an error occurs because paths are only resolved relative to the root directory.
My current workaround is adding a symlink in my root project.

Describe your proposed solution(s)

Add support for the patches-file configuration for dependencies and use dependency/package root that defines a patch to resolve relative paths for patches.

Describe alternatives

Add documentation that an external patch file only works for root projects (although this does not make a lot of sense to me).
To resolve the relative path issue an alternative could be to copy all gathered patches into a temp dir.

Additional context

No response

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