Skip to content

Commit f4270a0

Browse files
author
José Valim
committed
Do not touch lock manifest if there is no change
1 parent a696b9c commit f4270a0

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

lib/mix/lib/mix/deps/lock.ex

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ defmodule Mix.Deps.Lock do
5858
def write(dict) do
5959
sorted = lc { app, rev } inlist Enum.sort(dict), rev != nil, do: { app, rev }
6060

61-
lines = Enum.map_join sorted, ",\n ", fn { app, rev } ->
62-
%b("#{app}": #{inspect rev, raw: true, limit: :infinity})
63-
end
61+
unless sorted == read do
62+
lines = Enum.map_join sorted, ",\n ", fn { app, rev } ->
63+
%b("#{app}": #{inspect rev, raw: true, limit: :infinity})
64+
end
6465

65-
File.write! lockfile, "[ " <> lines <> " ]\n"
66-
touch
66+
File.write! lockfile, "[ " <> lines <> " ]\n"
67+
touch
68+
end
6769
end
6870
end

lib/mix/test/mix/deps/lock_test.exs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Code.require_file "../../test_helper.exs", __DIR__
2+
3+
defmodule Mix.Deps.LockTest do
4+
use MixTest.Case
5+
6+
test "creates new lock and manifest files" do
7+
in_fixture "no_mixfile", fn ->
8+
Mix.Deps.Lock.write [foo: :bar]
9+
assert File.regular? "mix.lock"
10+
assert File.regular? "ebin/.compile.lock"
11+
end
12+
end
13+
14+
test "does not touch manifest file there is no change" do
15+
in_fixture "no_mixfile", fn ->
16+
Mix.Deps.Lock.write [foo: :bar, bar: :bat]
17+
File.rm! "ebin/.compile.lock"
18+
19+
Mix.Deps.Lock.write [bar: :bat, foo: :bar]
20+
refute File.regular? "ebin/.compile.lock"
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)