Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/git_ops/commit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule GitOps.Commit do
# 40/41 are `(` and `)`, but syntax highlighters don't like ?( and ?)
type =
optional(whitespace)
|> tag(ascii_string([not: ?:, not: 40, not: 41], min: 1), :type)
|> tag(ascii_string([not: ?:, not: ?!, not: 40, not: 41], min: 1), :type)
|> optional(whitespace)

scope =
Expand All @@ -35,9 +35,9 @@ defmodule GitOps.Commit do

defparsecp(
:commit,
optional(breaking_change_indicator)
|> concat(type)
type
|> concat(optional(scope))
|> concat(optional(breaking_change_indicator))
|> ignore(ascii_char([?:]))
|> concat(message),
inline: true
Expand Down
15 changes: 12 additions & 3 deletions test/commit_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@ defmodule GitOps.Test.CommitTest do
assert parse!("feat: An awesome new feature!").message == "An awesome new feature!"
end

test "a breaking change via exlamation mark is parsed as a breaking change" do
assert parse!("!feat: A breaking change").breaking?
@tag :regression
test "a breaking change via a prefixed exclamation mark fails to parse" do
assert Commit.parse("!feat: A breaking change") == :error
end

test "a breaking change via a postfixed exclamation mark is parsed as a breaking change" do
assert parse!("feat!: A breaking change").breaking?
end

test "a breaking change via a postfixed exclamation mark after a scope is parsed as a breaking change" do
assert parse!("feat(stuff)!: A breaking change").breaking?
end

test "a simple feature is formatted correctly" do
assert format!("feat: An awesome new feature!") == "* An awesome new feature!"
end

test "a breaking change does not include the exclamation mark in the formatted version" do
assert format!("!feat: An awesome new feature!") == "* An awesome new feature!"
assert format!("feat!: An awesome new feature!") == "* An awesome new feature!"
end
end