How to add a fork to a composer Project - Part 2
This is a follow up from an older post How to add a fork to a composer Project
With Merge Requests being the default on Drupal.org now, I am finding I need to do this more, while for many requests I can add the patch from the MR itself, by adding .diff or .patch to the end of the MR URL, to add a patch in composer e.g.:
A patch for https://git.drupalcode.org/project/guardr/-/merge_requests/2 can be linked to in the composer json file by using https://git.drupalcode.org/project/guardr/-/merge_requests/2.diff
So I could add the patch to that profile by running:
composer config --json --merge extra.patches.drupal/guardr '{"#3231491: Drupal 9 branch": "https://git.drupalcode.org/project/guardr/-/merge_requests/2.diff"}'
This is useful for short term testing, but shouldn't be used in production in case the generated patch changes upstream.
Sometime I need to use the branch itself, instead of patching the module.
I can add the forked repository and then target the branch in composer by first adding the repo with:
composer config repositories.guardr vcs git@git.drupal.org:issue/guardr-3231491.git
then requiring that module but using the specific branch by adding dev- in front of the branch name, e.g.:
composer require drupal/guardr:dev-3231491-create-9.x-release
This can be useful when testing out branches that add the next Drupal version to a module for example.
Add new comment