Skip to content

Commit d9d4329

Browse files
author
Jason Kuhrt
authored
feat(cc): subject-line bang for breaking change (#88)
closes #87 Adds support for conventionalcommits.org/en/v1.0.0/#commit-message-with-to-draw-attention-to-breaking-change
1 parent 69041a7 commit d9d4329

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/lib/conventional-commit.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ describe(calcBumpType.name, () => {
77
expect(calcBumpType(false, ['unknown', 'feat: 1'])).toEqual('minor')
88
expect(calcBumpType(false, ['unknown\n\nBREAKING CHANGE: foo\nfoobar'])).toEqual(null)
99
expect(calcBumpType(false, ['unknown', 'fix: 1\n\nBREAKING CHANGE: foo'])).toEqual('major')
10+
expect(calcBumpType(false, ['unknown', 'fix!: 1\n\nBREAKING CHANGE: foo'])).toEqual('major')
11+
expect(calcBumpType(false, ['unknown', 'fix!: 1'])).toEqual('major')
1012
})
1113

1214
describe('initial development', () => {

src/lib/conventional-commit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ export type ConventionalCommit = {
7474
completesInitialDevelopment: boolean
7575
}
7676

77-
const pattern = /^([^:\r\n(]+)(?:\(([^\r\n()]+)\))?:\s*([^\r\n]+)[\n\r]*(.*)$/s
77+
const pattern = /^([^:\r\n(!]+)(?:\(([^\r\n()]+)\))?(!)?:\s*([^\r\n]+)[\n\r]*(.*)$/s
7878

7979
export function parse(message: string): null | ConventionalCommit {
8080
const result = message.match(pattern)
8181
if (!result) return null
82-
const [, type, scope, description, rest] = result
82+
const [, type, scope, breakingChangeMarker, description, rest] = result
8383

8484
let completesInitialDevelopment = false
85-
let breakingChange = null
85+
let breakingChange = breakingChangeMarker === undefined ? null : 'No Explanation'
8686
let body = null
8787
let footers: ConventionalCommit['footers'] = []
8888

0 commit comments

Comments
 (0)