mirror of
https://github.com/conventional-commits/conventionalcommits.org.git
synced 2026-03-22 12:44:37 -05:00
Resolving ambiguity in the spec #50
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mrwilson on GitHub (Oct 11, 2018).
Hi!
I'm a big fan of conventional commits, and have been using it on most of our work projects and all of my personal projects, so thank you.
I've been trying to implement a parser for the spec here and have a question.
Given
and
How can automated process tell the difference between a commit message with just a description and a commit message with just a footer?
Thanks,
Alex
@damianopetrungaro commented on GitHub (Oct 13, 2018):
Hey @mrwilson thank you for the issue!
At the moment there's no way to distinguish them.
Do you have an issue with it?
If you have an idea to improve the specs you're welcome!
@mrwilson commented on GitHub (Oct 15, 2018):
Hi,
My issue is that it means I can't properly implement a parsing library for the spec (yet!), and I thought it would be good to have a reference implementation for the spec?
How would I go about proposing an amendment to the spec? I have an idea.
Thanks! :)
@damianopetrungaro commented on GitHub (Oct 15, 2018):
Feel free to suggest it here!
Any idea is welcome! 💪
@mrwilson commented on GitHub (Oct 15, 2018):
Thanks! Here is a rough outline and I'm happy to formalise it into proper language if acceptable.
Proposal
Amend the spec to require delimiting 'body' with bullets (whether
*or-) and leave 'footer' as a bare line.Examples
We've informally adopted this at my workplace and we've found it an easy step - so you end up with commits like below, using
e9b5f40e16as an example:So 'body' is the section delimited by
*and the footer contains theCo-Authored-Bystatements.I believe this also increases readability by empowering spec-followers to clearly separate different points.
Interoperability with Existing Spec
This doesn't interfere with existing semantics around e.g. BREAKING CHANGE, as in the body these would be subsumed into the line as below:
How does this sound as a sketch?
@damianopetrungaro commented on GitHub (Oct 15, 2018):
I don't think this implementation may solve the issue in a fashionable way.
You're adding noise to the commit message and it would be harder to read and understand.
See that you already have space as a separator for type+description/body/footer it doesn't make sense really to add a
Co-authored-bythat may not fit all the use cases (for example link a Jira issue).IMHO it may be sth way simpler such as a
___.An example:
And you can omit it if you do not have a footer.
Before continuing the discussion i would like to ask an opinion from other maintainers
@zeke @bcoe @hbetts
@mrwilson commented on GitHub (Oct 15, 2018):
I see what you mean - by the way, the
Co-Authored-Bycould be anything, it's just that's the kind of thing we put into our footers to attribute commits. The only change I'm proposing is bulletting the body section. For clarification, a generic example would be:I'd be happy with the separator solution too :)
@hutson commented on GitHub (Oct 16, 2018):
If there is no way to distinguish between them, then why have specify two separate sections?
Any change to the spec that requires additional effort on the part of a committer would need to provide compelling value. Every additional requirement increases the likelihood of it not being followed correctly.
My opinion is that the specification does not provide justification for having two separate sections, a footer and a body.
@damianopetrungaro commented on GitHub (Oct 16, 2018):
The point is that IMHO there's no value splitting them.
The body+footer section can always be used together and could be treated as a better explanation of the commit.
@bcoe commented on GitHub (Oct 16, 2018):
one option, perhaps you can't have a footer without a body? and if there are just two sections, always assume header and body?
@damianopetrungaro commented on GitHub (Oct 16, 2018):
@bcoe Both are optional so you may have only the body, only the footer or both of them.
@bcoe commented on GitHub (Oct 16, 2018):
why don't we indicate that the
footeris an optional part of thebodybut can't exist without thebody; wipes hands, done.I think this might fit with what the angular folks are also advocating.
@mrwilson commented on GitHub (Oct 16, 2018):
As a day-to-day user, I personally prefer 'having only one section' to 'footer only exists within body'.
For both work and personal projects, I mainly use the footer for attributing commit authors but it's common to have a footer but not a body. (see
1c776e063dfor an example)@damianopetrungaro commented on GitHub (Oct 16, 2018):
Maybe we can find a name for the entire section that includes body and footer so that there is no BC in the tools that are supporting conventional commit.
wdyt @bcoe ?
@bcoe commented on GitHub (Oct 17, 2018):
@stevemao @ajoslin @Tapppi @hbetts any thoughts about how to fix this in the spec? my concern is that the conventional-commits parsers do parse the footer I believe? how does the parser deal with this ambiguity?
@mrwilson commented on GitHub (Oct 22, 2018):
I think it'd be good to add a reference implementation too, whichever way this gets resolved. That can be a separate issue though.
@zeke commented on GitHub (Oct 22, 2018):
Here's what parse-commit-message does:
@bcoe commented on GitHub (Oct 22, 2018):
@zeke et al., this seems reasonable to me; if there are two more elements, it's a
bodyandfooter, if there's one more element, it's always assumed to just be abody.Personally I don't think we need to overcomplicate things for the edge-case of a footer, let's just make sure the language of the spec reflects the conditional nature of the footer.
@zeke commented on GitHub (Oct 22, 2018):
That makes sense to me, but I think the implementation above is actually different:
footerseems to take precedence overbody. Maybe @tunnckoCore had a reason for writing it this way?@damianopetrungaro commented on GitHub (Oct 22, 2018):
@zeke
@bcoe commented on GitHub (Oct 22, 2018):
@zeke @@tunnckoCore whoops, misread; this feels weird; my workflow, which I've found works quite well, is that I almost always only write the
typeanddescriptionline, unless it's a BREAKING CHANGE, at which point I fill in abodywith a thorough description of the breaking change...I can imagine a workflow where I use a footer, e.g., Node.js populating this with reviewers, but it definitely feels like the less frequently used section of a commit message.
tldr; my preference would be if there are three sections, assume the third is
footerif there are two assume the second isbody.@bcoe commented on GitHub (Oct 22, 2018):
☝️ I think we could describe this with a tiny bit of clarification in the section of the spec around footers, without adding much to the spec?
@mrwilson commented on GitHub (Oct 23, 2018):
@bcoe - it sounds like it would be enough to replace
with
Happy to open a pull-request.
@tunnckoCore commented on GitHub (Oct 23, 2018):
Glance reading through the thread, i'm agree. I had no some special reason to did it that way.
@bcoe commented on GitHub (Oct 23, 2018):
@mrwilson 👍 sounds great to me, could I convince you to make a pull request 😄 many hands make for light lifting.
@mrwilson commented on GitHub (Oct 23, 2018):
@bcoe I have done so, hope I made the change in the right place!
@damianopetrungaro commented on GitHub (Oct 23, 2018):
Yes,
nextis the right place 😄@hutson commented on GitHub (Oct 26, 2018):
conventional-commits-parseris kind of a reference implementation though it's regular expressions are pretty accepting of most commit message conventions.@mrwilson commented on GitHub (Oct 26, 2018):
@hbetts Cool - I discovered the spec issue by trying to implement a module that encompasses the spec using a parser library.
Here if you're interested: https://github.com/mrwilson/conventional-commit/