Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
michaelw85 opened this issue Apr 11, 2023 · 10 comments · May be fixed by #518
Closed
4 tasks done
Labels
enhancement New features, options, or other additions.

Comments

@michaelw85
Copy link

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

@michaelw85 michaelw85 added the enhancement New features, options, or other additions. label Apr 11, 2023
@github-actions
Copy link

👋 Thanks for the idea! Please remember that this is an open source project - feature requests may or may not be implemented, and if they are, the timeline is unknown. If you need a guaranteed implementation or timeline, sponsorships are welcome!

@stale
Copy link

stale bot commented May 11, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 11, 2023
@stale stale bot closed this as completed May 18, 2023
@michaelw85
Copy link
Author

Automatically closing doesn't seem right to me. It would be nice to see a response acknowledging or declining the ticket

@gitressa
Copy link

gitressa commented Jun 5, 2023

I agree, perhaps the staleness threshold has been set to low, at one month? It seems very fast ...

@cweagans
Copy link
Owner

cweagans commented Jul 1, 2023

Hi all, apologies for the quick close and radio silence. I was trying out the stale bot and the thresholds were indeed set too low.

At this point, the 2.x version isn't going to support importing patches/patch defs from dependencies. It's a pretty complicated problem and an endless source of support requests and bugs. I do not have the time or energy to devote to it and I just can't commit to maintaining that particular functionality right now.

If you feel very strongly about having this kind of workflow (and being able to define patches via imported dependencies in general), I'd be glad to help you start up a plugin that extends this one and get you pointed in the right direction and give you an early heads up on where you might run into complications.

@michaelw85
Copy link
Author

@cweagans thanks for the reply.
It would be nice to at least add a little bit of documentation on this limitation and a work-around.
I could do that if you want.

@cweagans
Copy link
Owner

cweagans commented Jul 1, 2023

I'm never going to turn down help with docs! 😄

Couple of potentially helpful tidbits:

  • there is some info about how to write docs in this project here: https://docs.cweagans.net/meta/
  • this is related to the removal of dependency patch resolution in 2.x, which was being discussed earlier this year. I'm about to publish a blog post (in the next few days) about that decision which may have some helpful info.
  • this functionality can also be added by extending Composer Patches (you can write a plugin for the plugin!) if you really need it.

@michaelw85
Copy link
Author

@cweagans I've created a PR to extend the documentation based on the info I reported here. I think the description is quite extensive, feel free to edit/reduce the text if you feel it's too much.

@cweagans
Copy link
Owner

cweagans commented Jul 1, 2023

Thanks! I'll take a look ASAP.

@rajeshreeputra
Copy link

@cweagans Not sure but I started something here to apply patches from local and from url(lile from drupal.org patch file url).
Looking for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, options, or other additions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants