Skip to content

Commit 4cd577b

Browse files
committed
Fix Mix.Dep.Lock.write/2 ignoring :file option when comparing changes
Signed-off-by: Chae-JS <jschae02@khu.ac.kr>
1 parent 35eeab3 commit 4cd577b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/mix/lib/mix/dep/lock.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ defmodule Mix.Dep.Lock do
4242
def write(map, opts \\ []) do
4343
lockfile = opts[:file] || lockfile()
4444

45-
if map != read() do
45+
if map != read(lockfile) do
4646
if Keyword.get(opts, :check_locked, false) do
4747
Mix.raise(
4848
"Your #{lockfile} is out of date and must be updated without the --check-locked flag"

lib/mix/test/mix/dep/lock_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ defmodule Mix.Dep.LockTest do
4646
end)
4747
end
4848

49+
test "does not raise with check_locked when custom lockfile is unchanged", context do
50+
in_tmp(context.test, fn ->
51+
custom_lockfile = Path.expand("custom.lock")
52+
53+
Mix.Dep.Lock.write(%{foo: :bar})
54+
Mix.Dep.Lock.write(%{bar: :baz}, file: custom_lockfile)
55+
56+
Mix.Dep.Lock.write(%{bar: :baz}, file: custom_lockfile, check_locked: true)
57+
end)
58+
end
59+
4960
test "raises a proper error if check_locked opt is true and there are changes", context do
5061
in_tmp(context.test, fn ->
5162
Mix.Dep.Lock.write(%{foo: :bar})

0 commit comments

Comments
 (0)