Skip to content

Commit 139da8f

Browse files
committed
Only check for lock files in non-path dependencies (see #15158)
1 parent 8fdef5c commit 139da8f

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

lib/mix/lib/mix/dep.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,11 @@ defmodule Mix.Dep do
474474
%{dep | status: {:scmlock, old_scm}}
475475

476476
{:ok, _, _, old_lock} when old_lock != lock ->
477-
%{dep | status: :compile}
477+
if scm.fetchable?() do
478+
%{dep | status: :compile}
479+
else
480+
dep
481+
end
478482

479483
:error ->
480484
if scm.fetchable?() do

lib/mix/test/mix/tasks/compile.elixir_test.exs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ defmodule Mix.Tasks.Compile.ElixirTest do
667667

668668
Mix.Task.clear()
669669
File.write!("_build/dev/lib/sample/consolidated/.to_be_removed", "")
670-
manifest_data = :erlang.term_to_binary({:v1, "0.0.0", nil})
670+
manifest_data = :erlang.term_to_binary({2, "0.0.0", Mix.SCM.Path, nil})
671671
File.write!("_build/dev/lib/sample/.mix/compile.elixir_scm", manifest_data)
672672
File.touch!("_build/dev/lib/sample/.mix/compile.elixir_scm", @old_time)
673673

@@ -689,17 +689,33 @@ defmodule Mix.Tasks.Compile.ElixirTest do
689689
assert Mix.Dep.ElixirSCM.read() == {:ok, @elixir_otp_version, Mix.SCM.Path, nil}
690690

691691
Mix.Task.clear()
692-
manifest_data = :erlang.term_to_binary({1, @elixir_otp_version, :another})
693-
File.write!("_build/dev/lib/sample/.mix/compile.elixir_scm", manifest_data)
692+
Mix.Dep.ElixirSCM.update("_build/dev/lib/sample/.mix/", UnknownSCM, nil)
694693
File.touch!("_build/dev/lib/sample/.mix/compile.elixir_scm", @old_time)
695694

696695
Mix.Tasks.Compile.run([])
697696
assert Mix.Dep.ElixirSCM.read() == {:ok, @elixir_otp_version, Mix.SCM.Path, nil}
698-
699697
assert mtime("_build/dev/lib/sample/.mix/compile.elixir_scm") > @old_time
700698
end)
701699
end
702700

701+
test "recompiles project if lock changes except for path dependencies" do
702+
in_fixture("no_mixfile", fn ->
703+
Mix.Project.push(MixTest.Case.Sample)
704+
Mix.Tasks.Compile.run(["--verbose"])
705+
purge([A, B])
706+
707+
assert_received {:mix_shell, :info, ["Compiled lib/a.ex"]}
708+
assert Mix.Dep.ElixirSCM.read() == {:ok, @elixir_otp_version, Mix.SCM.Path, nil}
709+
710+
Mix.Task.clear()
711+
Mix.Dep.ElixirSCM.update("_build/dev/lib/sample/.mix/", Mix.SCM.Path, :whatever)
712+
File.touch!("_build/dev/lib/sample/.mix/compile.elixir_scm", @old_time)
713+
714+
assert Mix.Tasks.Compile.run([]) == {:noop, []}
715+
assert Mix.Dep.ElixirSCM.read() == {:ok, @elixir_otp_version, Mix.SCM.Path, :whatever}
716+
end)
717+
end
718+
703719
test "recompiles project if old manifest" do
704720
in_fixture("no_mixfile", fn ->
705721
Mix.Project.push(MixTest.Case.Sample)

0 commit comments

Comments
 (0)