Skip to content

Commit 47f57d6

Browse files
committed
Merge pull request #2170 from ericmj/mix-unloaded-name
Fetch if remote converger updated dependency lock
2 parents 0246226 + ed71b57 commit 47f57d6

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

lib/mix/lib/mix/dep.ex

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,6 @@ defmodule Mix.Dep do
111111
{ Mix.Dep.Converger.topsort(deps), acc, lock }
112112
end
113113

114-
@doc """
115-
Receives a list of dependency names and maps and reduces over
116-
them. See `unloaded`.
117-
118-
## Exceptions
119-
120-
This function raises an exception if any of the dependencies
121-
provided in the project are in the wrong format.
122-
"""
123-
def unloaded_by_name(given, acc, lock, opts, callback) do
124-
names = to_app_names(given)
125-
126-
unloaded(acc, lock, opts, fn dep, acc, lock ->
127-
if dep.app in names do
128-
callback.(dep, acc, lock)
129-
else
130-
{ dep, acc, lock }
131-
end
132-
end)
133-
end
134-
135114
@doc """
136115
Runs the given `fun` inside the given dependency project by
137116
changing the current working directory and loading the given

lib/mix/lib/mix/dep/fetcher.ex

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,29 @@ defmodule Mix.Dep.Fetcher do
2626
See `Mix.Dep.unloaded_by_name/4` for options.
2727
"""
2828
def by_name(names, old_lock, new_lock, opts) do
29-
result = Mix.Dep.unloaded_by_name(names, [], new_lock, opts, &do_fetch/3)
29+
fetcher = fetch_by_name(names, new_lock)
30+
result = Mix.Dep.unloaded([], new_lock, opts, fetcher)
3031
{ apps, deps } = do_finalize(result, old_lock, opts)
31-
Mix.Dep.loaded_by_name(names, deps, opts) # Check all given dependencies are loaded or fail
32+
33+
# Check if all given dependencies are loaded or fail
34+
Mix.Dep.loaded_by_name(names, deps, opts)
3235
apps
3336
end
3437

38+
defp fetch_by_name(given, lock) do
39+
names = to_app_names(given)
40+
41+
fn(%Mix.Dep{app: app} = dep, acc, new_lock) ->
42+
# Only fetch if dependency is in given names or if lock has
43+
# been changed for dependency by remote converger
44+
if app in names or lock[app] != new_lock[app] do
45+
do_fetch(dep, acc, new_lock)
46+
else
47+
{ dep, acc, new_lock }
48+
end
49+
end
50+
end
51+
3552
defp do_fetch(dep, acc, lock) do
3653
%Mix.Dep{app: app, scm: scm, opts: opts} = dep = check_lock(dep, lock)
3754

@@ -123,4 +140,10 @@ defmodule Mix.Dep.Fetcher do
123140

124141
do_with_depending(parents, all_deps) ++ parents
125142
end
143+
144+
defp to_app_names(given) do
145+
Enum.map(given, fn(app) ->
146+
if is_binary(app), do: binary_to_atom(app), else: app
147+
end)
148+
end
126149
end

0 commit comments

Comments
 (0)