Skip to content

Commit

Permalink
lock => the lock in solver failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed Oct 30, 2022
1 parent 5f17d16 commit a756557
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 29 deletions.
10 changes: 7 additions & 3 deletions lib/hex/solver.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver do
_ = """
Expand Down Expand Up @@ -51,8 +51,12 @@ defmodule Hex.Solver do
{:ok, result()} | {:error, String.t()}
def run(registry, dependencies, locked, overrides, opts \\ []) do
case Solver.run(registry, dependencies, locked, overrides) do
{:ok, solution} -> {:ok, Map.drop(solution, ["$root", "$lock"])}
{:error, incompatibility} -> {:error, Failure.write(incompatibility, opts)}
{:ok, solution} ->
{:ok, Map.drop(solution, ["$root", "$lock"])}

{:error, incompatibility} ->
IO.inspect(incompatibility)
{:error, Failure.write(incompatibility, opts)}
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/assignment.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Assignment do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraint.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defprotocol Hex.Solver.Constraint do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/empty.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Empty do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/impl.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Impl do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/range.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Range do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/union.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Union do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/util.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Util do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/constraints/version.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Constraints.Version do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/failure.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Failure do
@moduledoc false
Expand Down
8 changes: 4 additions & 4 deletions lib/hex/solver/incompatibility.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Incompatibility do
@moduledoc false
Expand Down Expand Up @@ -59,7 +59,7 @@ defmodule Hex.Solver.Incompatibility do
},
opts
) do
"\"lock\" specifies #{bright_term_abs(dependee, opts)}"
"\"the lock\" specifies #{bright_term_abs(dependee, opts)}"
end

def to_string(
Expand Down Expand Up @@ -379,7 +379,7 @@ defmodule Hex.Solver.Incompatibility do
do: bright("your app", opts)

defp package_name(%Term{package_range: %PackageRange{name: "$lock"}}, opts),
do: bright("lock", opts)
do: bright("the lock", opts)

defp package_name(%Term{package_range: %PackageRange{repo: nil, name: name}}, opts),
do: bright(name, opts)
Expand All @@ -399,7 +399,7 @@ defmodule Hex.Solver.Incompatibility do
do: bright("your app", opts)

defp terse_every(%Term{package_range: %PackageRange{name: "$lock"}}, opts),
do: bright("lock", opts)
do: bright("the lock", opts)

defp terse_every(term, opts) do
if Constraint.any?(term.package_range.constraint) do
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/package_lister.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.PackageLister do
@moduledoc false
Expand Down
4 changes: 2 additions & 2 deletions lib/hex/solver/package_range.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.PackageRange do
@moduledoc false
Expand All @@ -11,7 +11,7 @@ defmodule Hex.Solver.PackageRange do
constraint: nil

def to_string(%PackageRange{name: "$root"}), do: "your app"
def to_string(%PackageRange{name: "$lock"}), do: "lock"
def to_string(%PackageRange{name: "$lock"}), do: "the lock"

def to_string(%PackageRange{repo: nil, name: name, constraint: constraint}),
do: "#{name}#{constraint(constraint)}"
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/partial_solution.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.PartialSolution do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/registry.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Registry do
_ = """
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/requirement.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Requirement do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/solver.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Solver do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/term.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Term do
@moduledoc false
Expand Down
2 changes: 1 addition & 1 deletion lib/hex/solver/util.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually
# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually

defmodule Hex.Solver.Util do
@moduledoc false
Expand Down
8 changes: 4 additions & 4 deletions test/hex/solver_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ defmodule Hex.SolverTest do

test "failure due to locked dep" do
assert solve([ex_plex: "0.1.0", decimal: nil], decimal: "0.0.1") == """
Because "lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0".
And because "your app" depends on "lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden.
Because "the lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "the lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0".
And because "your app" depends on "the lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden.
So, because "your app" depends on "ex_plex 0.1.0", version solving failed.\
"""

assert solve([decimal: nil, ex_plex: "0.1.0"], decimal: "0.0.1") == """
Because "lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0".
And because "your app" depends on "lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden.
Because "the lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "the lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0".
And because "your app" depends on "the lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden.
So, because "your app" depends on "ex_plex 0.1.0", version solving failed.\
"""

Expand Down

0 comments on commit a756557

Please sign in to comment.