patch_0.jpg

How to create a patch for a Drupal module

Friday, September 24, 2010 - 10:15

Short walkthrough on how to create a patch for a Drupal module using Git and Giggle.

First make sure your issue is not already reported by someone else in the issue queue for the module. Also check out the latest dev version of the module, is the issue resolved there? If all statements above equals FALSE lets make a patch:

  1. Start the terminal and download the module to your test environent with Drush. drush dl [module-name]

  2. Enter the directory and initialize an empty repository cd [module-name] git init

  3. Add the files to you repository git add *

  4. Commit the files to the repository git commit -m 'Initial commit'

  5. Make your awesome changes to the file you want to change.

  6. Commit your changes to git git commit -m 'Description what you've changed'

  7. Start Giggle, at the bottom right of the application window you will find a button named Details, click this then click on your initial commit and copy the SHA-tag (looks something like this: 325449643c76dbeade12033d8304f447e53742d9) Click on your next commit and copy the SHA-tag from that.

  8. Enter the terminal and execute the command below

git diff --no-prefix [original-SHA] [patched-SHA] > my-patchfile.patch

  1. File an issue at the project page for module you have patched and mark the issue as needs review. Make sure you select the correct version for the module. If available, post a screenshot of the problem and the solution.

Attachment

application-octet-stream_128.png