Skip to content

Commit

Permalink
improvement: Make opts merge silent when values are identical (ash-pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
jechol authored May 29, 2024
1 parent 92bde6a commit a1b67cc
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/spark/dsl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -636,19 +636,23 @@ defmodule Spark.Dsl do

@doc false
def merge_with_warning(left, right, path, overwriting_by \\ nil) do
Keyword.merge(left, right, fn key, left, right ->
by =
if overwriting_by do
" by #{overwriting_by}"
else
""
end
Keyword.merge(left, right, fn
_, left, left ->
left

key, left, right ->
by =
if overwriting_by do
" by #{overwriting_by}"
else
""
end

IO.warn(
"#{Enum.join(path ++ [key], ".")} is being overwritten from #{inspect(left)} to #{inspect(right)}#{by}"
)
IO.warn(
"#{Enum.join(path ++ [key], ".")} is being overwritten from #{inspect(left)} to #{inspect(right)}#{by}"
)

right
right
end)
end
end

0 comments on commit a1b67cc

Please sign in to comment.