When I fix an issue, I like to link to the commit. However, this requires at least 3 clicks from an issue:

  1. Click the link in the breadcrumbs to the project page
  2. Click the link at the upper-right to the list of commits
  3. Click the link to the actual commit
  4. (optional) Click the link to the diff

Not counting scrolling to the top of the issue page, copying the final link, scrolling back down to the comment textarea, and pasting in the link.

Instead of doing all this, I wrote a script that does it for me; it gets the URL of the most recent commit to the current project and inserts it as a link into the comment textarea when a button is clicked. The script is attached in patch form for dreditor, in two versions:

  • dreditor-get-last-commit.patch gets the URL of the diff of the last commit. This requires overriding jQuery.ajax to use YQL as an intermediary for cross-site requests, because commit pages are on drupalcode.org and not drupal.org.
  • dreditor-get-last-commit-nodiff.patch just gets the URL of the commit page itself. This doesn't require anything fancy.

Both patches make use of a new function insertAtCaret(), which inserts the result link into the comment textarea at the caret position. (If the user hasn't focused on the textarea yet, the caret position is 0.)

I haven't made any attempt to handle cases where the comment textarea isn't on an issue page, and I've only tested in FF10. It also takes a few seconds to load the intermediate pages.