Drush Issue Queue Commands

Drush provides a set of commands to make interacting with the issue queue on Drupal.org easier. In particular, the workflow described by the advanced patch contributor guide (http://drupal.org/node/1054616) is followed, so the patch files generated will contain information crediting the authors. The Drush issue queue commands makes it much easier for beginners, and much faster for beginning and experienced git users alike to create and apply patches.

Applying Patches

Patches can be applied with the Drush iq-apply-patch command. The Drush iq commands work best with projects that are cloned from their git repository on Drupal.org, either by following the instructions at http://drupal.org/project/project-name/git-instructions, or by using the --package-handler=git_drupalorg modifier with Drush pm-download.

  $ drush pm-download uuid --package-handler=git_drupalorg
  $ cd uuid
  $ drush iq-apply-patch 1236768
These commands may either be executed from within a working Drupal site, or stand-alone, just to see what the patch looks like in context. If you download the module into a working Drupal site, it is not necessary to cd to the project directory before running the ip-apply-patch command; Drush can find the project directory on its own.

Once you execute these commands, Drush will go out and find the most recent patch that has been posted on the given project, and apply it using either git am or patch, as appropriate. If you do not want to apply the most recent patch, then you can append the comment number to the end of the issue id; for example, to take the patch from the seventh comment of issue 1236768:

  $drush iq-apply-patch 1236768-#7
Finally, you might sometimes find it convenient to specify a patch via the full URL to the issue node, like so:
  $drush iq-apply-patch http://drupal.org/node/1236768
This form is handy to use when viewing a project's issue queue; you may copy the issue URL to your clipboard by right-clicking on it, and then paste it into a terminal window to use with iq-apply-patch, all without needing to re-visit the issue in the browser to find the most recent patch.

Before the patch is applied, Drush will create a new branch to store your changes in. This step is optional, and can be subverted by supplying the --no-git option to iq-apply-patch. By default, most iq commands do not modify the state of your repository; the automatic creation of the Drush iq branch is one exception.

Creating Patches

After testing and modifying your patch, you may wish to create a new version of the patch to post back to the issue queue. This may be done with the Drush iq-diff command.

  $ drush iq-diff
The iq-diff command will attempt to use the git format-patch to create the patch, but if you do not desire this, the --no-git option may be used to create a simple patch instead. Note that by design, the git format-patch requires that all modified code be committed to the issue branch before it can be included in the patch. The iq-diff command will create a temporary commit to run the format-patch on, but it then immediately backs the commit out again, leaving all of your changes in an unstaged state. This is done so that the Drush iq commands can be used quickly, without worrying about accumulating unwanted commits in your iq branch. If you are a more experienced git user, and prefer to keep these commits around to show the history of the patch's development, you may retain them by specifying the --commit flag when running drush iq-diff.

Committing Changes

As previously mentioned, it is possible to commit changes to your iq branch using the --commit flag with drush iq-diff. If you would prefer to commit your changes via git directly, you may; in this instance, you might want to use the iq-create-commit-comment command to facilitate a quick commit. The iq-create-commit-comment command is aliased to ccc, so you can quickly commit via:

  $ git add .
  $ git commit -m "`drush ccc`"

Cleaning Up

When you are done with an iq branch, you may clean it up with an iq-reset command.

  $ drush iq-reset
This will preserve your iq branch so that you may return to it later. Note that in order for this to work correctly, you must commit your unstaged changes to your iq branch first. If you do not commit, then all of your unstaged changes will come with you when you return to the previous main branch that the iq branch was split off from. This is standard git behavior, and the iq commands maintain it.

If you are completely done with the iq branch, you may use the --hard option to perminently delete it. Since it is easy to re-create the branch with iq-apply-patch, it is safe to remove your iq branches after you have posted your changes as a new patch on the issue.