Messages with an exclamation mark after type ("feat!") fail with Angular config
See original GitHub issueIndicating breaking changes with !
after type does not work when extending Angular config, but should be possible according to Conventional Commits 1.0.0.
I’m using this project through the Github Action, which currently uses commitlint 9.0.1 under the hood.
Expected Behavior
Commit message like feat!: the message has an exclamation mark
should pass the lint.
Current Behavior
Lint does not pass with the following error message:
⧗ input: feat!: the message has an exclamation mark ✖ subject may not be empty [subject-empty] ✖ type may not be empty [type-empty]
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
A workaround is to extend config-conventional
instead.
.commitlintrc.yml
:
extends:
- '@commitlint/config-conventional'
Since they are different, desired rules from config-angular
have to also be defined below, but they are not relevant to this bug so they have been omitted.
A proper solution would be to fix this in commitlint
.
Steps to Reproduce (for bugs)
- In the repository root create file:
.commitlintrc.yml
:
extends:
- '@commitlint/config-angular'
- Enable Github Actions with the following configuration:
.github/workflows/ci.yml
:
name: CI
on:
pull_request:
push:
jobs:
check_commit_conventions:
name: Check commit conventions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check commit conventions
uses: wagoid/commitlint-github-action@v2
with:
configFile: .commitlintrc.yml
failOnWarnings: true
- Push a commit with an exclamation mark and check CI pipeline.
A commenter from another issue faced problems with the version 9.0.1 as well, although he had them with config-conventional
, so it might be a separate problem.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (1 by maintainers)
Top GitHub Comments
I came across the issue as well using
config-angular
and alsoconfig-conventional
Did a lil digging, and found it’s just a regex pattern mismatch. Not a bug.config-angular
hasheaderPattern: /^(\w*)(?:\((.*)\))?: (.*)$/
andconfig-conventional
hasheaderPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/
If there’s no match due to the introduction of a
!
the committype
andscope
will not be foundI needed to match
fix!(170793): whats poppin son
and neither would work for me. Althoughconfig-conventional
allowsfix(170793)!: whats poppin son
orfix!: whats poppin son
, it isn’t what I wanted.This is what I used:
Thanks for the tip! I was surprised how long it took me to figure this out, but in the end, the
cli.ts
has a clue:https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/cli/src/cli.ts#L199
I found this worked for me in the end: