Skip to content

Commit 8506cc6

Browse files
author
José Valim
committed
Ensure conflict with umbrella children are shown, closes #4792
Signed-off-by: José Valim <[email protected]>
1 parent a1bbc1b commit 8506cc6

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

lib/mix/lib/mix/tasks/deps.check.ex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ defmodule Mix.Tasks.Deps.Check do
9595

9696
defp partition([dep | deps], not_ok, compile) do
9797
cond do
98-
from_umbrella?(dep) -> partition(deps, not_ok, compile)
99-
compilable?(dep) -> partition(deps, not_ok, [dep | compile])
100-
ok?(dep) and local?(dep) -> partition(deps, not_ok, [dep | compile])
101-
ok?(dep) -> partition(deps, not_ok, compile)
102-
true -> partition(deps, [dep | not_ok], compile)
98+
compilable?(dep) ->
99+
if from_umbrella?(dep) do
100+
partition(deps, not_ok, compile)
101+
else
102+
partition(deps, not_ok, [dep | compile])
103+
end
104+
ok?(dep) ->
105+
partition(deps, not_ok, compile)
106+
true ->
107+
partition(deps, [dep | not_ok], compile)
103108
end
104109
end
105110

@@ -123,7 +128,7 @@ defmodule Mix.Tasks.Deps.Check do
123128
defp compilable?(%Mix.Dep{status: {:noappfile, _}}), do: true
124129
defp compilable?(%Mix.Dep{status: {:scmlock, _}}), do: true
125130
defp compilable?(%Mix.Dep{status: :compile}), do: true
126-
defp compilable?(%Mix.Dep{}), do: false
131+
defp compilable?(%Mix.Dep{} = dep), do: ok?(dep) and local?(dep)
127132

128133
defp show_not_ok!([]) do
129134
:ok

lib/mix/test/mix/umbrella_test.exs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ defmodule Mix.UmbrellaTest do
135135
Mix.env(:test)
136136
end
137137

138-
test "loads umbrella child dependencies in umbrellas" do
138+
test "loads umbrella sibling dependencies with :in_umbrella" do
139139
in_fixture "umbrella_dep/deps/umbrella", fn ->
140140
Mix.Project.in_project :umbrella, ".", fn _ ->
141141
File.write! "apps/bar/mix.exs", """
@@ -157,6 +157,31 @@ defmodule Mix.UmbrellaTest do
157157
end
158158
end
159159

160+
test "finds umbrella sibling dependencies conflicts with :in_umbrella" do
161+
in_fixture "umbrella_dep/deps/umbrella", fn ->
162+
Mix.Project.in_project :umbrella, ".", fn _ ->
163+
File.write! "apps/bar/mix.exs", """
164+
defmodule Bar.Mixfile do
165+
use Mix.Project
166+
167+
def project do
168+
[app: :bar,
169+
version: "0.1.0",
170+
deps: [{:foo, in_umbrella: true, env: :unknown}]]
171+
end
172+
end
173+
"""
174+
175+
assert_raise Mix.Error, fn ->
176+
Mix.Tasks.Deps.Get.run []
177+
end
178+
179+
assert_received {:mix_shell, :error, ["Dependencies have diverged:"]}
180+
assert_received {:mix_shell, :error, [" the dependency foo in mix.exs is overriding a child dependency" <> _]}
181+
end
182+
end
183+
end
184+
160185
## Umbrellas as a dependency
161186

162187
test "list deps for umbrella as dependency" do

0 commit comments

Comments
 (0)