question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Exclamation Mark for Breaking Change Confuses Parser

See original GitHub issue

It appears that the conventional-commits-parser package doesn’t directly support the exclamation mark demarcation for noting a breaking change in a commit. Parsing the following commit measage:

chore!: drop node 8 support

Will yield a node with the following structure:

{
  type: null,
  scope: null,
  subject: null,
  merge: null,
  header: 'chore!: drop node 8 support',
  body: null,
  footer: null,
  notes: [],
  references: [],
  mentions: [],
  revert: null,
  hash: 'd0059c44727bd0562db42aedeed60713b698c264',
  breaking: false
}

A notable number of properties are left null in addition to not recognizing the ! indicating a breaking change. Support for ! is noted in the first item in the Specification https://www.conventionalcommits.org/en/v1.0.0/#specification.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:27
  • Comments:10

github_iconTop GitHub Comments

5reactions
fhenzcommented, Oct 7, 2020

I solved this by supplying the parser function with the second options parameter. The options argument includes the fields headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/ and breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/ which seemingly solved the issue. I got these options from the “conventional-changelog-conventionalcommits” package, i.e.

const parser = require("conventional-commits-parser");
const spec = require("conventional-changelog-conventionalcommits");
...
const options = await spec();
const parsed = parser.sync(COMMIT, options.parserOpts);

resulting with COMMIT as chore!: drop node 8 support in this:

{
  type: 'chore',
  scope: null,
  subject: 'drop node 8 support',
  merge: null,
  header: 'chore!: drop node 8 support',
  body: null,
  footer: null,
  notes: [ { title: 'BREAKING CHANGE', text: 'drop node 8 support' } ],
  references: [],
  mentions: [],
  revert: null
}
3reactions
carloschneidercommented, Jul 17, 2022

Exclamation works perfectly with conventionalcommits preset:

npx conventional-recommended-bump --preset conventionalcommits
Read more comments on GitHub >

github_iconTop Results From Across the Web

Anthony Fu on Twitter: "The issue: https://t.co/2lZkzXtw1V" / Twitter
Kinda surprised to see that conventional-changelog, the most popular changelog generator, does NOT support using exclamation marks for breaking changes ...
Read more >
Really Break Grammar Rules on Websites: Part 2
Break Rule #5: Use Exclamation Points Judiciously. Wordsmiths have baptized the exclamation point (!) a cheap attempt at forcing excitement upon ...
Read more >
Exclamation point breaks field queries - Elasticsearch
I just noticed that a field query that includes an exclamation point ("! ... If you don't want to use the lucene query...
Read more >
Can't use exclamation mark (!) in bash? - Unix Stack Exchange
You might try to directly escape it with a backslash ( \ ) before the character (eg: "http://example.org/\!132" ). However, even though a...
Read more >
Exclamation Mark Uses & Examples - Video & Lesson Transcript
Understand the meaning of an exclamation mark in text with examples ... The punctuation at the end of a sentence can completely change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found