diff --git a/lib/changex/formatter/markdown.ex b/lib/changex/formatter/markdown.ex index 2b3138a..7d9e6f2 100644 --- a/lib/changex/formatter/markdown.ex +++ b/lib/changex/formatter/markdown.ex @@ -42,8 +42,8 @@ defmodule Changex.Formatter.Markdown do * commit 8 - hash """ - def format(commits, version \\ nil, opts \\ []) do - heading(version) <> types(commits, opts) + def format(commits, opts \\ []) do + heading(Keyword.get(opts, :version)) <> types(commits, opts) end defp heading(version) do diff --git a/lib/mix/tasks/changex/diff.ex b/lib/mix/tasks/changex/diff.ex index 2c4f555..0dff0ae 100644 --- a/lib/mix/tasks/changex/diff.ex +++ b/lib/mix/tasks/changex/diff.ex @@ -81,7 +81,7 @@ defmodule Mix.Tasks.Changex.Diff do Changex.Formatter.Terminal.output(commits, version) end defp output(commits, "markdown", version, opts) do - Changex.Formatter.Markdown.format(commits, version, opts) |> IO.puts + Changex.Formatter.Markdown.format(commits, Keyword.put(opts, :version, version)) |> IO.puts end defp output(commits, "elixir", version, opts) do Changex.Formatter.Elixir.format(commits, version: version) |> IO.puts diff --git a/lib/mix/tasks/changex/update.ex b/lib/mix/tasks/changex/update.ex index aad0724..bb5949c 100644 --- a/lib/mix/tasks/changex/update.ex +++ b/lib/mix/tasks/changex/update.ex @@ -48,12 +48,12 @@ defmodule Mix.Tasks.Changex.Update do end defp build(commits, previous, "markdown", opts) do - head = commits |> Changex.Formatter.Markdown.format(nil, opts) + head = commits |> Changex.Formatter.Markdown.format(opts) head <> "\n\n" <> previous end defp build(commits, previous, "elixir", opts) do - head = commits |> Changex.Formatter.Elixir.format(nil, opts) + head = commits |> Changex.Formatter.Elixir.format(opts) head <> "\n\n" <> previous end diff --git a/test/changex/formatter/markdown_test.exs b/test/changex/formatter/markdown_test.exs index 236d9d7..adf4d05 100644 --- a/test/changex/formatter/markdown_test.exs +++ b/test/changex/formatter/markdown_test.exs @@ -19,7 +19,7 @@ defmodule Changex.Formatter.MarkdownTest do end test "Formatting with an explicit version", %{commits: commits} do - assert Changex.Formatter.Markdown.format(commits, "v10") == expected_markdown("v10") + assert Changex.Formatter.Markdown.format(commits, version: "v10") == expected_markdown("v10") end test "Formatting with an implicit version", %{commits: commits} do @@ -28,7 +28,7 @@ defmodule Changex.Formatter.MarkdownTest do end test "Formatting with a github url", %{commits: commits} do - assert Changex.Formatter.Markdown.format(commits, "v10", [github: "gazler/changex"]) == expected_markdown_with_github + assert Changex.Formatter.Markdown.format(commits, [version: "v10", github: "gazler/changex"]) == expected_markdown_with_github end test "Formatting with a missing section" do @@ -43,7 +43,7 @@ defmodule Changex.Formatter.MarkdownTest do * **dashboard** * show number of bots on the dashboard (5c764b2957d1c6e7ed73e1691a55399c85b62c34) """ |> String.rstrip - assert Changex.Formatter.Markdown.format(commits, "v10") == expected + assert Changex.Formatter.Markdown.format(commits, version: "v10") == expected end defp expected_markdown(version) do