Skip to content

Commit

Permalink
patch: support bang for breaking changes as per Conventional Commit Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
idc101 committed May 18, 2021
1 parent 941497c commit 6077014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/scala/net/cardnell/mkver/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,16 @@ object AppConfig {
BranchConfig("hotfix[/-].*", Some(true), None, None, None, Some(false), None, None, None)
)
val defaultCommitMessageActions: List[CommitMessageAction] = List(
// Breaking changes (major)
CommitMessageAction("BREAKING CHANGE", IncrementAction.IncrementMajor),
CommitMessageAction("major(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("minor(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("patch(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("feature(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("feat(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("fix(\\(.+\\))?!:", IncrementAction.IncrementMajor),
// The rest of the conventional commits
CommitMessageAction("(build|ci|chore|docs|perf|refactor|revert|style|test)(\\(.+\\))?!:", IncrementAction.IncrementMajor),
CommitMessageAction("major(\\(.+\\))?:", IncrementAction.IncrementMajor),
CommitMessageAction("minor(\\(.+\\))?:", IncrementAction.IncrementMinor),
CommitMessageAction("patch(\\(.+\\))?:", IncrementAction.IncrementPatch),
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/net/cardnell/mkver/MkVerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ object MkVerSpec extends DefaultRunnableSpec {
test("should parse correctly") {
assert(calcBumps(List(" major: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true))) &&
assert(calcBumps(List(" feat: change", " BREAKING CHANGE"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true, minor = true))) &&
assert(calcBumps(List(" feat!: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true))) &&
assert(calcBumps(List(" fix!: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true))) &&
assert(calcBumps(List(" patch!: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true))) &&
assert(calcBumps(List(" major(a component)!: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(major = true))) &&
assert(calcBumps(List(" feat: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(minor = true))) &&
assert(calcBumps(List(" fix: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(patch = true))) &&
assert(calcBumps(List(" patch: change"), commitMessageActions, VersionBumps()))(equalTo(VersionBumps(patch = true))) &&
Expand Down

0 comments on commit 6077014

Please sign in to comment.