Skip to content

Commit

Permalink
Add RemoteConverger.post_converge/0 callback (elixir-lang#5074)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj authored Nov 4, 2016
1 parent e0affa0 commit 1b91bf1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/mix/lib/mix/dep/converger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ defmodule Mix.Dep.Converger do
"""
def converge(acc, lock, opts, callback) do
{deps, acc, lock} = all(acc, lock, opts, callback)
if remote = Mix.RemoteConverger.get, do: remote.post_converge()
{topsort(deps), acc, lock}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/hex.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Mix.Hex do
@moduledoc false
@hex_requirement ">= 0.5.0"
@hex_requirement ">= 0.14.0"
@hex_mirror "https://repo.hex.pm"

@doc """
Expand Down
6 changes: 6 additions & 0 deletions lib/mix/lib/mix/remote_converger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ defmodule Mix.RemoteConverger do
"""
@callback deps(Mix.Dep.t, map) :: [atom]

@doc """
Called after all convergers have run so that the remote
converger can perform clean up.
"""
@callback post_converge() :: any

@doc """
Gets registered remote converger.
"""
Expand Down
11 changes: 4 additions & 7 deletions lib/mix/test/mix/dep_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,14 @@ defmodule Mix.DepTest do
@behaviour Mix.RemoteConverger

def remote?(_app), do: true
def deps(_dep, _lock), do: []
def post_converge, do: :ok

def converge(deps, lock) do
Process.put(:remote_converger, deps)
lock
end

def deps(_dep, _lock) do
[]
end
end

test "remote converger" do
Expand Down Expand Up @@ -305,15 +304,13 @@ defmodule Mix.DepTest do
@behaviour Mix.RemoteConverger

def remote?(_app), do: false
def deps(_dep, _lock), do: :ok
def post_converge, do: :ok

def converge(_deps, lock) do
Process.put(:remote_converger, true)
lock
end

def deps(_dep, _lock) do
[]
end
end

test "remote converger is not invoked if deps diverge" do
Expand Down

0 comments on commit 1b91bf1

Please sign in to comment.