Skip to content

Commit

Permalink
feat(cc): subject-line bang for breaking change (#88)
Browse files Browse the repository at this point in the history
closes #87

Adds support for conventionalcommits.org/en/v1.0.0/#commit-message-with-to-draw-attention-to-breaking-change
  • Loading branch information
Jason Kuhrt authored Aug 5, 2020
1 parent 69041a7 commit d9d4329
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/lib/conventional-commit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe(calcBumpType.name, () => {
expect(calcBumpType(false, ['unknown', 'feat: 1'])).toEqual('minor')
expect(calcBumpType(false, ['unknown\n\nBREAKING CHANGE: foo\nfoobar'])).toEqual(null)
expect(calcBumpType(false, ['unknown', 'fix: 1\n\nBREAKING CHANGE: foo'])).toEqual('major')
expect(calcBumpType(false, ['unknown', 'fix!: 1\n\nBREAKING CHANGE: foo'])).toEqual('major')
expect(calcBumpType(false, ['unknown', 'fix!: 1'])).toEqual('major')
})

describe('initial development', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/conventional-commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export type ConventionalCommit = {
completesInitialDevelopment: boolean
}

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

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

let completesInitialDevelopment = false
let breakingChange = null
let breakingChange = breakingChangeMarker === undefined ? null : 'No Explanation'
let body = null
let footers: ConventionalCommit['footers'] = []

Expand Down

0 comments on commit d9d4329

Please sign in to comment.