Skip to content

Commit 178b937

Browse files
author
José Valim
committed
Ensure path dependencies are compiled on mix deps.get
1 parent e49badd commit 178b937

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

lib/mix/lib/mix/scm/path.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ defmodule Mix.SCM.Path do
1818
path = "../#{app}"
1919

2020
opts
21-
|> Keyword.put(:path, path)
2221
|> Keyword.put(:dest, Path.expand(path))
22+
|> Keyword.put_new(:path, path)
2323
|> Keyword.put_new(:env, Mix.env)
2424
true ->
2525
nil
@@ -40,7 +40,7 @@ defmodule Mix.SCM.Path do
4040

4141
def checkout(opts) do
4242
path = Mix.Utils.relative_to_cwd opts[:dest]
43-
raise Mix.Error, message: "Cannot checkout path dependency. Expected a dependency at #{path}"
43+
raise Mix.Error, message: "cannot checkout path dependency, expected a dependency at #{path}"
4444
end
4545

4646
def update(opts) do

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ defmodule Mix.Tasks.Deps.Compile do
4848
shell.info "* Compiling #{app}"
4949

5050
deps_path = opts[:dest]
51-
5251
root_path = Path.expand(Mix.project[:deps_path])
5352

5453
config = [
@@ -123,7 +122,7 @@ defmodule Mix.Tasks.Deps.Compile do
123122
end
124123

125124
Mix.Task.run "local.rebar", []
126-
Mix.Rebar.local_rebar_cmd || raise Mix.Error, message: "Rebar instalation failed"
125+
Mix.Rebar.local_rebar_cmd || raise Mix.Error, message: "rebar instalation failed"
127126
end
128127

129128
defp do_command(app, command, extra // "") do

lib/mix/lib/mix/tasks/deps.get.ex

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,39 @@ defmodule Mix.Tasks.Deps.Get do
4949

5050
defp deps_getter(dep, { acc, lock }) do
5151
shell = Mix.shell
52-
dep = check_lock(dep, lock)
53-
54-
if out_of_date?(dep) do
55-
Mix.Dep[app: app, scm: scm, opts: opts] = dep
56-
shell.info "* Getting #{format_dep(dep)}"
57-
58-
old = lock[app]
59-
opts = Keyword.put(opts, :lock, old)
60-
61-
new =
62-
if scm.checked_out?(opts) do
63-
scm.update(opts)
52+
Mix.Dep[app: app, scm: scm, opts: opts] = dep = check_lock(dep, lock)
53+
54+
cond do
55+
# Path dependencies are specially handled because they cannot
56+
# be fetched although they are always compiled afterwards
57+
scm == Mix.SCM.Path ->
58+
{ dep, { [app|acc], lock } }
59+
60+
# If the dependency is not available or we have a lock mismatch
61+
out_of_date?(dep) ->
62+
shell.info "* Getting #{format_dep(dep)}"
63+
64+
old = lock[app]
65+
opts = Keyword.put(opts, :lock, old)
66+
67+
new =
68+
if scm.checked_out?(opts) do
69+
scm.update(opts)
70+
else
71+
scm.checkout(opts)
72+
end
73+
74+
if new do
75+
# Update the dependency returned so it is now
76+
# available and nested dependencies can be fetched
77+
{ Mix.Deps.update(dep), { [app|acc], Keyword.put(lock, app, new) } }
6478
else
65-
scm.checkout(opts)
79+
{ dep, { acc, lock } }
6680
end
6781

68-
if new do
69-
# Update the dependency returned so it is now
70-
# available and nested dependencies can be fetched
71-
{ Mix.Deps.update(dep), { [app|acc], Keyword.put(lock, app, new) } }
72-
else
82+
# The dependency is ok or has some other error
83+
true ->
7384
{ dep, { acc, lock } }
74-
end
75-
else
76-
{ dep, { acc, lock } }
7785
end
7886
end
7987
end

lib/mix/lib/mix/tasks/deps.update.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ defmodule Mix.Tasks.Deps.Update do
7373

7474
defp check_unavailable!(dep) do
7575
unless available?(dep) do
76-
raise Mix.Error, message: "Cannot update dependency #{dep.app} because " <>
76+
raise Mix.Error, message: "cannot update dependency #{dep.app} because " <>
7777
"it isn't available, run `mix deps.get` first"
7878
end
7979
dep

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ defmodule Mix.Tasks.DepsTest do
263263
Mix.Tasks.Deps.Get.run []
264264
message = "* Getting git_repo [git: #{inspect fixture_path("git_repo")}]"
265265
assert_received { :mix_shell, :info, [^message] }
266+
assert_received { :mix_shell, :info, ["* Compiling deps_repo"] }
266267
assert_received { :mix_shell, :info, ["Generated git_repo.app"] }
267268

268269
Mix.Tasks.Deps.Update.run ["--all"]
269270
assert_received { :mix_shell, :info, ["* Updating deps_repo (0.1.0) [path: \"custom/deps_repo\"]"] }
271+
assert_received { :mix_shell, :info, ["* Compiling deps_repo"] }
270272
end
271273
after
272274
Mix.Project.pop

0 commit comments

Comments
 (0)