Problem/Motivation
Drupal's Git commit message standards are problematic, example:
Issue #[issue number] by [comma-separated usernames]: [Short summary of the change]
Issue #2771547 by Lendude, klausi, dawehner, alexpott, pwolanin: In Browser and FunctionalJavascript tests SIMPLETEST_USER_AGENT cookie needs to be set every 5 seconds
- The description of what has actually changed is at the very end
- The type of change is not included in this example. Bugfix? Or new feature? Or cleanup? Or documentation? We have guidelines to use "Fixed/Added/Changed" verbs, but we do not consistently use them.
- The affected area/component/scope of Drupal is not included. It is hard to see if this change should concern me or not without doing more git archeology for each commit
- Depending on the number of contributors to a change the beginning of the message has a variable length. That makes it very hard to read multiple lines of the commit log:
####### <actual message here> ########################### <actual message here> ## <actual message here> ########### <actual message here> ############# <actual message here>
- It is not possible to auto-generate a changelog from the commit messages and group them in a meaningful way. For release notes we want to have a list of new features and a separate list of bugfixes for example.
Proposed resolution
Use the AngularJS commit message conventions as template and adapt it to our needs. The commit message from above would change to:
[type]([scope]): [Short summary of the change] (issue #[issue number] by [comma-separated usernames])
fix(phpunit): in Browser and FunctionalJavascript tests SIMPLETEST_USER_AGENT cookie needs to be set every 5 seconds (#2771547 by Lendude, klausi, dawehner, alexpott, pwolanin)
[type] can be (we can also just use a subset of those or invent more types):
- feat (feature)
- fix (bug fix)
- docs (documentation)
- style (formatting, missing semi colons, …)
- refactor
- test (when adding missing tests)
- chore (maintain)
[scope] can be the module name, or the component name or the subsystem of Drupal core.
More examples:
- feat(outside_in): [Experimental] Create Outside In module MVP to provide block configuration in Off-Canvas tray and expand site edit mode (issue xyz by abc)
- docs(menu_ui): incorrect summary line for menu_ui_form_node_type_form_validate() (issue xyz by abc)
- style(whitespace): fix 'Drupal.WhiteSpace.OpenTagNewline' coding standard (issue xyz by abc)
- refactor(diff): further refactor use of SafeMarkup in HWLDFWordAccumulator (issue xyz by abc)
- test(node): add test coverage for Views revision link handlers (issue xyz by abc)
- chore(symfony): update symfony-cmf/routing to 1.4.0 (issue xyz by abc)
Note that commit messages will still be just one line for now, using multiple lines for commit messages is discussed in #2811033: Discuss if git commit messages should be multiple lines.
The proposed new standard is available as experimental doc page at https://www.drupal.org/node/2825448 . The content of it should become the new git message standard eventually.
Remaining tasks
- Discuss and build consent.
- Use the new experimental standard in your contrib projects and report back
Comments
Comment #2
klausitypo
Comment #3
mglaman+1 for this. You can't read core/contrib commits and know what happened. Putting issue number and credits at end is useful. If not even pushing commit credit mentions to new line so it isn't part of the main summary.
When I was working on a Drupal SaaS and having to review git logs of projects we used to see incoming changes it was near impossible to do a simple grok of the commit list.
EDIT: It'd be nice to also compare AngularJS style to other projects.
Comment #4
joachim CreditAttribution: joachim as a volunteer commented> The type of change is not included. Bugfix? Or new feature? Or cleanup? Or documentation?
That's not correct. The current commit message standard requires the first word of the description to a verb which tells you that, usually one of 'Fixed'/'Changed'/'Added'.
Now since d.org added the JS that produces the git command for you, that's mostly not been happening, because the JS uses the issue title to create the commit message description, and people aren't bothering to edit what's suggested.
Comment #5
subhojit777+1 for this suggestion. And also +1 for Matt's suggestion. Instead of putting everything inside the commit summary, few things can be put inside the commit description.
Like this:
Commit message based on this template:
We can then program the Bot to parse the third line of commit and give credits to the user.
This way the commit summary looks cleaner.
Reference:
- http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
- http://chris.beams.io/posts/git-commit
Comment #6
joaogarin CreditAttribution: joaogarin commented+1 for this suggestion. Drupal could extend the types or adapt to what fits best since these are flexible and this opens up possibility for a lot of good things like using Semantic relaease for managing releases on github, using clog cli for automatic CHANGELOG generation (also used by angularJs both 1 and 2 and many other frameworks) and a number of other tools that can make good use of such a commit style.
great suggestion!
Comment #7
Grayside CreditAttribution: Grayside at Phase2 for Norwegian Cruise Line commentedThis kind of rearrangement would be very useful, especially given how http://cgit.drupalcode.org/ truncates the commit messages.
Not as sure about burying useful information in the description -- most tools don't really access that.
Comment #8
klausi@joachim: right, updated issue summary.
@subhojit777: commit credit is very important to the Drupal community and moving that further down might be a bit too much for this issue. Also I'm against long git commit summaries: if there is something important to say put that into code comments and change record documentation on drupal.org so that people can find it. There is a reason we have the issue reference in a commit message for further information.
Comment #9
joachim CreditAttribution: joachim as a volunteer commentedI think this is an interesting idea. Machine-parseable commit logs have lots of potential applications. But I think it needs more discussion as I'm not sure the exact AngularJS format is right for us.
In particular, I'd like to see the issue number much closer to the front of the message.
I'm also really not keen on the commit message running to multiple lines: same as #8, for more detail there's the issue, the code comments, and the change record.
Comment #10
pfrenssen+1 for having a detailed commit message spanning multiple lines.
Comment #11
naveenvalecha+1 for the detailed message but the [Short summary of the change] should come in start instead of the credits
Comment #12
klausiThe advantage of sticking to already established formatting standards is that we can use the same tooling as for example AngularJS uses to auto-create changelogs.
I prefer the issue number at the end because it is just a reference and has itself no information what the commit changed. Github for example also adds the issue number to the end if you squash merge a pull request. AngularJS adds the issue number on a separate line at the very end. Having issue numbers at the end also seems to be an established standard.
Comment #13
webchickNote there's a lot of prior art on revamping commit strings at #2323715: [policy, no patch] Determine format for commit credit for individuals/organizations/customers, though based on Linux's template rather than Angular's.
Comment #14
klausiFeedback from xjm on this:
* We should get the Technical Working Group involved because they oversee policy decisions like this that affect standards that apply to Drupal core and Drupal contrib
* We should have a concise list of Drupal core components that we reference in the scope part of the commit message, because it seems we don't have that? Contrib modules would of course invent their own scopes. For example rules would use "actions", "conditions", "UI", "expressions", "scheduler" and similar.
Now that the feedback in this issue is overly positive I think we can start an experimental documentation page where we fork the current git commit message document. That way Drupal contrib can already start to experiment and adopt this new standard and we can evaluate how well it works in Drupal reality.
Comment #15
fgm+1 to the detailed commits too: when you're offline, the commit messages are often all you get to have an idea of what a commit is about; not everyone is constantly online.
-1 to removing the Issue number from the first line: when browsing comments, finding the issue# in a well-known place makes it easier to go to it. If we start using longer summaries, multiple issues might end up being mentioned, and we would lose the "reference" aspect of the issue# in the one-liner comment on top of the issue.
Comment #16
klausiThere was also the concern that drupal.org expects a certain commit message format regarding issue numbers, but as you see for example in the Coder commit stream the connection to issues works just fine at the end https://www.drupal.org/node/105916/commits
Comment #17
klausiOpened #2809773: Provide feedback on changing our git commit message format to get the blessings of the TWG.
Comment #18
klausiOpened #2811033: Discuss if git commit messages should be multiple lines.
This issue is just about changing the arrangement of our single line git commit messages, please discuss multiple lines for git commit messages in the other issue.
Comment #19
klausiI created a new experimental doc page at https://www.drupal.org/node/2825448
It is supposed to become the new git messages document in the long run once this issues gets approved by the Technical Working Group.
I made some minor changes to be even more in line with AngularJS.
Please review!
Otherwise feel free to experiment with this new format in your contrib projects now! Would love to get some feedback on practical use and your experiences.
Comment #20
pfrenssenOK if this is about the single line format I am not in favor. I don't like this format. What I don't like about it:
git log -- core/modules/node
). It is not necessary to mention this in the commit message, and especially not in the first line of the commit message.git log --oneline
. Keeping it at the front also makes it line up nicely. I would drop the current "Issue #" part from it, only keeping "123456".To me the AngularJS format seems badly thought out and not suitable for us. -1
If we are going towards machine parseable data we should not cram it in the first line of the commit message.
My proposal:
Comment #21
chx CreditAttribution: chx at Smartsheet, Migrate Rocks commented#1282040: Add support for reading git-notes
Using `git notes` for doling out real contribution credit
Comment #22
DamienMcKennaThis doesn't have the benefit of resolving some of the bigger problems we currently have with our commit messages, like #2323715: [policy, no patch] Determine format for commit credit for individuals/organizations/customers does, it just reformats the string to add two meta data items to the commit message and make them more prominent than that was previously displayed. -1 for me.
Comment #23
pfrenssenI think we should consider these issues together, the reworking of the first line, determining the format for commit credit, and hashing out the possibility of a multiline commit message. It is very likely that each of these issues influence the other.
Ideally we could work out a good format that satisfies all three and then make a single announcement for the new format. Otherwise we risk that people will have to learn a new commit message format three times in a short period of time.
Comment #24
klausiAh, finally a bit of resistance. Glad I could provoke it by posting the doc page :)
This change of git commit message format would be very beneficial when you casually look at the git log to keep track of what is going on in the development of the project. When you do that the issue type is very important (that's why it is in the first place). What features have been introduced since last week? Were there any bugfixes at all? Have there been refactorings I should be aware of?
Terminology of issue types: I would not invent a Drupalism by using our own types. The proposed types are used in many projects and give you a uniform experience when looking at the git log.
Unneeded scope: of course you can do archeology with git to find out more. But when skimming over a commit log you don't want to invoke multiple git commands. You want a high level summary of changes and what part those changes affect. So I argue that the scope is very important. And
git log -- core/modules/node
fails pretty badly when you move files and directories around, git does not properly follow it.Issue number at the front: An issue number does not give you any information when trying to understand a message. It is very useful to look something up, but a human cannot make any sense out of the number alone. It should definitely be there, but in the beginning it is just something a human needs to read over to get to the actual message contents. That's why you see issue numbers on Github or other places always at the end.
Another problem: Currently the beginning of our git commit messages lines has a different length depending on the number of contributors. It looks something like this in git log:
So for a human it is very hard to read multiple lines of the git log because you have to constantly scan the line where the message begins. That gives me real headaches when I want to get an overview.
Contrary to that the AngularJS commit message conventions are carefully thought out to be accessible to humans to get a quick understanding of changes in commit logs. If we adopt them it would be more than just moving stuff around within the message, we make them easier to read and give necessary context.
@pfrenssen: Your proposal would definitely be an improvement, but having issue numbers without leading "#" is not used anywhere else. I would rather stick to existing standards instead of inventing our own.
Comment #25
pfrenssenI'd really love to have the issue number in front, and I'm not alone with this desire, @joachim also mentioned a preference to have it close to the front in comment #9. The comment of @fgm in #15 also indicates that the issue number is important to him.
I dropped the # because a line starting with this symbol is regarded as a comment by Git and is ignored. I would still be OK with `Issue #123456: xxx` though.
Well no, I think the issue number is the most important thing in the message, and this is due to our particular patch based workflow. If I look at a commit message I mostly do this because I want to know the issue number. I think for as long as we are going to keep committing huge kilobyte sized patches with the necessary background information spread across hundreds of comments in an issue, then the issue number is the thing you really care about :)
Another problem: the messages have a different length. With the AngularJS standard it will look something like this in git log:
;)
We've been using them for 10 years so our standard is as good as anyone else's, and it is better for us since it matches what we use in the issue queue.
I also think that there is no such thing as an "uniform experience", but there is common terminology:
"Chore" is not the standard term at all as you can see.
This is exactly why I want the issue number in front, then the message, then the commit credit in the back. Then everything is as well aligned as we can make it.
I have a little tip for you that you will find very useful :)
$ git log --follow
What I also find a really strong argument is that putting the issue number at or near the front is a standard that is widely adopted by other projects. Here are some examples:
I like the format from Symfony, that has most of the things we want, including commit credit.
Comment #26
klausiSide note rant about
git log --follow -- core/modules/node
: Oh, so the first commit for node module is in 2011? But wait that is the exact time we moved everything under the core folder? Which means that git log --follow does not actually work. You have to come up with even more git black magic just to be able to track moved files ;-)Comment #27
pfrenssenGit doesn't track folders, you need to use actual filenames, then it works fine:
git log --follow -- core/modules/node/node.module
Goes all the way back to:
Comment #28
joachim CreditAttribution: joachim as a volunteer commented> Git doesn't track folders, you need to use actual filenames, then it works fine:
Thing is, our modules and components are folders, not files...
The idea of having formal names for each component or module, that's machine-parseable, is growing on me :) But we'd have to be REALLY strict about it when making commits, otherwise it's just adding not-quite-human-readable junk to the commit log. (I am wary of this because of how lax everyone is about our existing commit message format. This has been especially bad since d.org started suggesting commit messages, which means the convention of starting them with Fixed/Changed/Added has totally gone out of the window.)
> Another problem: Currently the beginning of our git commit messages lines has a different length depending on the number of contributors.
+1 to the first portion of the message being fixed length, or nearly fixed length. (Issue numbers are going to be 7 digits for a while, but there are still older issues getting fixed....)
I don't think the AngularJS format is right for us. I think we're going to have to invent a Drupalism, though maybe one that's concocted from existing ideas.
Comment #29
pfrenssenWell if we really want to borrow a format from another project we could take the format from Symfony:
Examples:
bug #2771547 [Render API] Link title double escaping in Link::preRenderLink (kgoel, ifrik)
feature #123446[outside_in] Create Outside In module MVP to provide block configuration in Off-Canvas tray and expand site edit mode (jessebeach)
docs #123456 [menu_ui] Incorrect summary line for menu_ui_form_node_type_form_validate() (emma.maria)
task #123456 [symfony] Update symfony-cmf/routing to 1.4.0 (jensimmons)
This has all the parts from the AngularJS one, doesn't have the awkward formatting with the missing space, has the issue number in front, and is more easily machine parseable than what we have now.
But as I said in #23, I think we should fix all our commit message problems at once. Otherwise we would now introduce a new one-line format, and then a bit later change it again to move the credits to a multiline format for #2323715: [policy, no patch] Determine format for commit credit for individuals/organizations/customers.
Comment #31
jthorson CreditAttribution: jthorson commentedThe TWG was asked to provide input into this issue (over at #2809773: Provide feedback on changing our git commit message format). We discussed the issue during our meeting on January 31st, 2017, and have the following comments:
Comment #32
joachim CreditAttribution: joachim as a volunteer commented> the TWG would be interested in a wider body of research prior to implementing any change in the commit message format, illustrating the strengths and opportunities this proposed format provides us over other non-Drupal options which may or may not have been considered.
I agree that we should widen the discussion. Not just to consider a list of existing formats, but to try to determine what we want from a commit message format.
A quick and incomplete list of questions we should consider:
- which elements are the most important?
- which should have placement priority, either at the start or the end of the line?
- how important is it to use an existing format rather than devise something?
Then we can look at both existing formats and new ones and sum up which criteria each one satisfies.
Comment #44
smustgrave CreditAttribution: smustgrave at Mobomo commentedbumping back to the front after 6 years. Part of our needs review queue.
Comment #45
joachim CreditAttribution: joachim as a volunteer commentedSadly, since we have MR merging built into d.org, hardly anyone uses even our existing commit message format!
Comment #46
BerdirThat's simply not true, if you use the UI on drupal.org it uses the suggested commit message. Sure, some people don't follow that, but they also didn't before merge requests were a thing.
Plus, this is a core issue, where everyone follows the current standard.
Comment #47
smustgrave CreditAttribution: smustgrave at Mobomo commentedAs nod_ brought up in slack does this belong in the idea queue?
Comment #48
joachim CreditAttribution: joachim as a volunteer commented> That's simply not true, if you use the UI on drupal.org it uses the suggested commit message.
I can't find it, but the standard for the format at one point was that the description should begin with one of Fixed/Added/Changed. The d.org UI gives you 'Issue #2802947: ISSUE_TITLE' and so nobody uses the first verb any more.
Comment #49
BerdirAdded/Fixed/Changed was promoted for a while by a group of people (sun being one of them IIRC) that created the recommend commit message guideline for contrib maintainers. It was never actually used by core. Before "Issue #NUMBER" was used it was just "#NUMBER", the switch to the Issue prefix happened as part of switching Git, because starting a commit message with # caused problems when editing them.
The first commit to use the current format was twelve years ago:
In other words, it has been like this for a very long time and has nothing to with merge requests, if you want to blame something then blame Git, but even before that it wasn't what you think it was :)
Comment #50
nod_For this core repository I think the ship has sailed, most likely possibility to change the commit message format would be: #3220688: [policy] Use conventional commit format
For me this is won't fix at this point I don't see the value. It would also break many scripts relying on the current format for not much benefit.
Maybe the release managers want to change how they manage release notes, so tagging accordingly
Comment #51
nod_The credit system will not rely on commit message so there is no need to change the commit message format for this purpose see #3327584: New contribution records system
Comment #52
nod_Sorry too soon
Comment #53
DamienMcKennaThere are also some related issues in the drupalorg project queue, e.g. #2955276: Automatically generate release notes when new release is tagged.
Comment #54
quietone CreditAttribution: quietone at PreviousNext commentedThe release managers have discussed this issue. No one preferred this particular format. There was also concern that an implementation would be disruptive by breaking a decade of log parsers. Although, the latter is likely true for any change to the commit message.
Other ideas can continue to be discussed in the earlier issue, #2323715: [policy, no patch] Determine format for commit credit for individuals/organizations/customers
Therefor, we all agree with @nod_ that it it time to close this issue.