Skip to content

Fix error message for diverged SCM definition in sibling #13493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lib/mix/lib/mix/dep/converger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,30 @@ defmodule Mix.Dep.Converger do
# on, there is no lock, so we won't hit this branch.
lock = if lock_given?, do: remote.converge(deps, lock), else: lock

# Build a cache using both dep_name and dep_scm to ensure we only
# return :loaded for deps which have been loaded from the same source.
cache =
deps
|> Enum.reject(&remote.remote?(&1))
|> Enum.into(%{}, &{{&1.app, &1.scm}, &1})
|> Enum.into(%{}, &{&1.app, &1})

# In case no lock was given, we will use the local lock
# which is potentially stale. So remote.deps/2 needs to always
# check if the data it finds in the lock is actually valid.
{deps, acc, lock} =
init_all(main, apps, acc, lock, callback, lock_given?, env_target, fn dep ->
if cached = cache[{dep.app, dep.scm}] do
{:loaded, cached}
else
{:unloaded, dep, remote.deps(dep, lock)}
%{app: app, scm: scm} = dep

case cache do
# If the SCM matches, use the already cached dependency from first converger pass
%{^app => %{scm: ^scm} = cached} ->
{:loaded, cached}

# If SCM doesn't match, the remote converger resolved a new dependency but because
# there is conflict we return the new dependency as is for the converger to fail
%{^app => _cached} ->
{:loaded, dep}

%{} ->
{:unloaded, dep, remote.deps(dep, lock)}
end
end)

Expand Down