I've had this question several times and found it hard to find the answer. So, if only for my own reference, here it is!
If you need to use the code from a Drupal issue fork (rather than a patch) in Composer, you need to...
1. Get the URL of the issue fork.
You can find this on the issue page itself. For example, on this issue for Entity Group Field, you can get it here next to where it says "Issue fork":
Copy that URL. In this case, it's https://git.drupalcode.org/issue/entitygroupfield-3306512
2. Find the particular commit in that issue fork that you want to use.
If you look under "Commits" on the GitLab page, you can find the commit hash of the one you want. In this case, we'll use this commit:
Its hash is "2fd46a02ae6ceca69ab81083463c7ba28434a75e".
Note that using a specific hash makes your site a bit more secure. If you just used the HEAD of the branch, you could end up using whatever the last commit pushed to this issue branch was. That could break your site (or worse!).
3. Add a new "repositories" section to your composer.json file.
This should go above the existing entries in the repositories section. Note that I'm using the name of the Drupal package (drupal/entitygroupfield), the URL of the issue fork and the hash of the commit (from above). The "version" should match that of the package you're using.
diff --git a/composer.json b/composer.json
index 9a268b889..abeeb4aa4 100644
--- a/composer.json
+++ b/composer.json
@@ -9,6 +9,19 @@
"chat": "https://www.drupal.org/node/314178"
},
"repositories": {
+ "entitygroupfield": {
+ "type": "package",
+ "package": {
+ "name": "drupal/entitygroupfield",
+ "version": "1.0.x-dev",
+ "type": "drupal-module",
+ "source": {
+ "url": "https://git.drupalcode.org/issue/entitygroupfield-3306512.git",
+ "type": "git",
+ "reference": "2fd46a02ae6ceca69ab81083463c7ba28434a75e"
+ }
+ }
+ },
"lenient": {
"type": "composer",
"url": "https://packages.drupal.org/lenient"
4. Include the module using Composer.
Now, you can "run "composer require" to add the module code from the issue fork:
composer require drupal/entitygroupfield:1.0.x-dev
Make sure to specify the version you set above.
That's does it! Now, you've got the code with the changes you need. You will need to update that commit has and run "composer require" again if you want to change the particular commit you're using.
1 Comment
I did it like:
"repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8", "exclude": [ "drupal/riddle_marketplace" ] }, { "type": "vcs", "url": "https://git.drupalcode.org/issue/riddle_marketplace-3289392.git" } ],
and then:
composer require drupal/riddle_marketplace:dev-8.x-3.x#8f0d00c6562970e62ddee75c1b42ef3a829c1314