Drupal Contrib Attribution and Credit with Magit for Emacs
Third-party Drupal modules, like Drupal itself, are a community effort. I maintain several of these modules, and they are made better when helpful users submit patches to the modules' issue queues.
When users submit these improvements, I've made some effort to give credit where credit is due. Just days ago I learned, via a somewhat random conversation at BADCamp, that I've been doing this wrong. So before writing any more on the subject, I apologize to everyone who's submitted a patch lately. More often than not I tried to credit you on drupal.org. Turns out I didn't, but I just didn't know.
In my defense, I've been trying to attribute credit exactly the way prescribed on Drupal.org. According to that article, the trick is simply in the commit message. From that article:
Use this syntax for commit messages:
Issue #[issue number] by [comma-separated usernames]: [Short summary of the change].
For example:
Issue #52287 by sun, Dries: Fixed outdated commit message standards.
Note the punctuation.
That's easy enough. And this used to work back in the long ago days when Drupal used CVS for version control. Trouble is, it no longer works with git. At least it is not the complete correct technique.
Now, with git, we need to add a command line option to the git commit command. This has been documented elsewhere, for example this year-old article by Ryan S.
For this attribution argument to work it has to be exactly right, so drupal.org recommends copying and pasting it to get the right syntax.
Today I committed a good patch to modules/fb, and I wanted to properly give credit to dooberman. Drupal.org shows me the command line option I need to use (on the user's drupal.org profile page):
Pass the following option to git commit to attribute authorship to this user:
--author="git <git@242515.no-reply.drupal.org>"
Learn more about proper Git attribution.
So, just to review, in the past, when committing to drupal.org, we were expected to copy and paste two values in the commit message (the issue number and the patch authors' names). Now, we are expected to continue doing that, plus copy an additional argument to the command line. Do do this properly, we have to copy three different values (the issue id, the user's name, and the user's git attribution), found on two different drupal.org pages (the issue, and the user profile). Frankly, I find this pretty inconvenient. But as far as I know, it is the right way.
I rarely use git on the command line. I use a tool called magit for emacs which I find easier to use. Fortunately, magit has an option that lets me change the author when committing. Magit users, when authoring a commit message, run magit-log-edit-toggle-author
(shortcut: C-c C-t
). Then when authoring a commit message, you'll be able to edit the author attribution.
So, returning to that issue which dooberman helpfully found and fixed, I wrote the following commit message in magit:
Author: "git <git@242515.no-reply.drupal.org>"<br>-- End of Magit header --<br>Fixes #1829706 by dobeerman: proper variable names for fb_stream settings.
Now, I only wish I could report that it worked properly! I've pushed the fix, but don't yet see any attribution on dooberman's commits page. I'm hopeful it just takes drupal.org some time to change the page, and I'll update this post if I learn that it has worked.
[Update - it worked. It just took Drupal.org some time to display the properly attributed commit.]
Tags: