Answers.Body: <p>Drupal 8/CiviCRM has the <a href="https://github.com/cweagans/composer-patches" rel="nofollow noreferrer">composer-patches</a> package already installed.  So you can add a section to the <code>"extra"</code> element in <code>composer.json</code> called <code>"patches"</code>, and list out the patch with a title and a URL (or path) to a <code>.diff</code> file.  Here's an example where I add four patches to standard CiviCRM:</p>
  
  
  
  <pre><code>diff --git a/composer.json b/composer.json
  index 453ff74..5827a69 100644
  --- a/composer.json
  +++ b/composer.json
  @@ -68,6 +68,14 @@
           ]
       },
       "extra": {
  +        "patches": {
  +          "civicrm/civicrm-core": {
  +            "core#609, PR 13390.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13390.diff",
  +            "core#580, PR 13373.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13373.diff",
  +            "membership#9, PR#13553 (membership renewal notification fix)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13553.diff",
  +            "reporting#8, PR 13653 (thank-you dates on contribution reports)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13653.diff"
  +          }
  +        },
           "patchLevel": {
               "drupal/core": "-p2"
           },
  </code></pre>
  
  <p><strong>Note:</strong> If you don't use the excellent <code>roundearth/civicrm-composer-plugin</code> but instead use the <a href="https://www.mydropwizard.com/blog/how-install-civicrm-drupal-8-and-why-choose-it-over-pure-drupal-crm" rel="nofollow noreferrer">full manual process</a> to update CiviCRM, you'll need to perform the update steps every time you run <code>composer install</code> with patches.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T22:09:45.187Z
Answers.LastActivityDate: 2019-02-20T22:35:05.640Z
Answers.LastEditDate: 2019-02-20T22:35:05.640Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I sometimes need to fix a bug in CiviCRM before that bug is fixed in the latest version of CiviCRM.  With non-composer installations, I patch my dev site, commit my changes to <code>git</code>, and push them to a repo, then deploy to test/live sites.</p>
  
  <p>Using composer, CiviCRM isn't in my git repo.  What's a reasonable way to manage patches so they a) persist across upgrades, b) can be managed in <code>git</code>?</p>
  
  <p><strong>Alternately:</strong> I'd like to test a patch that someone thinks will fix a bug in my CiviCRM installation.  How can I do that?</p>
  
Tags: <drupal-8><composer>
Title: How can I install/manage CiviCRM patches on Drupal 8 (using Composer)?
ThreadText: # How can I install/manage CiviCRM patches on Drupal 8 (using Composer)?
  
  (Asked by: username_0 on 2019-02-20)
  
  I sometimes need to fix a bug in CiviCRM before that bug is fixed in the latest version of CiviCRM. With non-composer installations, I patch my dev site, commit my changes to `git`, and push them to a repo, then deploy to test/live sites.
  
  Using composer, CiviCRM isn't in my git repo. What's a reasonable way to manage patches so they a) persist across upgrades, b) can be managed in `git`?
  
  **Alternately:** I'd like to test a patch that someone thinks will fix a bug in my CiviCRM installation. How can I do that?
  
  **Tags:** drupal-8, composer
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-02-20. Score: 3
  
  Drupal 8/CiviCRM has the composer-patches package already installed.  So you can add a section to the "extra" element in composer.json called "patches", and list out the patch with a title and a URL (or path) to a .diff file.  Here's an example where I add four patches to standard CiviCRM:
  diff --git a/composer.json b/composer.json
  index 453ff74..5827a69 100644
  --- a/composer.json
  +++ b/composer.json
  @@ -68,6 +68,14 @@
           ]
       },
       "extra": {
  +        "patches": {
  +          "civicrm/civicrm-core": {
  +            "core#609, PR 13390.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13390.diff",
  +            "core#580, PR 13373.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13373.diff",
  +            "membership#9, PR#13553 (membership renewal notification fix)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13553.diff",
  +            "reporting#8, PR 13653 (thank-you dates on contribution reports)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13653.diff"
  +          }
  +        },
           "patchLevel": {
               "drupal/core": "-p2"
           },
  
  Note: If you don't use the excellent roundearth/civicrm-composer-plugin but instead use the full manual process to update CiviCRM, you'll need to perform the update steps every time you run composer install with patches.
  
  
  ---
  
  