Permalink
Browse files

Add optional requirements for activated dep

  • Loading branch information...
ericmj committed Jul 12, 2015
1 parent c23f942 commit bab7f2fb2cdc22984ab4ad1f985546c0ce8ac621
Showing with 23 additions and 14 deletions.
  1. +3 −0 CHANGELOG.md
  2. +4 −4 lib/hex/resolver.ex
  3. +4 −5 lib/mix/tasks/hex/publish.ex
  4. +4 −4 mix.lock
  5. +1 −1 test/hex/registry_test.exs
  6. +5 −0 test/hex/resolver_test.exs
  7. +2 −0 test/test_helper.exs
View
@@ -3,6 +3,9 @@
* Enhancements
* Warn if registry file is missing when loading deps
* Bug fixes
* Consider new optional requirements for already activated dependency
## v0.8.0 (2015-05-19)
* Enhancements
View
@@ -94,7 +94,7 @@ defmodule Hex.Resolver do
active = active(active, possibles: possibles, version: version)
info = info(info, deps: deps)
{new_pending, new_optional, new_deps} = get_deps(app, name, version, info)
{new_pending, new_optional, new_deps} = get_deps(app, name, version, info, activated)
pending = pending ++ new_pending
optional = merge_optional(optional, new_optional)
info = info(info, deps: new_deps)
@@ -106,7 +106,7 @@ defmodule Hex.Resolver do
defp activate([request(app: app, name: name, parent: parent)|pending], [version|possibles],
optional, info(deps: deps) = info, activated) do
{new_pending, new_optional, new_deps} = get_deps(app, name, version, info)
{new_pending, new_optional, new_deps} = get_deps(app, name, version, info, activated)
new_pending = pending ++ new_pending
new_optional = merge_optional(optional, new_optional)
@@ -145,7 +145,7 @@ defmodule Hex.Resolver do
end
end
defp get_deps(app, package, version, info(top_level: top_level, deps: all_deps)) do
defp get_deps(app, package, version, info(top_level: top_level, deps: all_deps), activated) do
if deps = Registry.get_deps(package, version) do
all_deps = attach_dep_and_children(all_deps, package, deps)
@@ -160,7 +160,7 @@ defmodule Hex.Resolver do
cond do
was_overridden?(upper_breadths, String.to_atom(app)) ->
{reqs, opts}
optional ->
optional && !activated[name] ->
{reqs, [request|opts]}
true ->
{[request|reqs], opts}
@@ -208,7 +208,7 @@ defmodule Mix.Tasks.Hex.Publish do
{code, _} when code in 200..299 ->
true
{code, body} ->
Mix.shell.error("Updating package #{meta[:name]} failed")
Mix.shell.error("\nUpdating package #{meta[:name]} failed")
Hex.Utils.print_error_result(code, body)
false
end
@@ -225,11 +225,10 @@ defmodule Mix.Tasks.Hex.Publish do
case Hex.API.Release.new(meta[:name], tarball, auth, progress) do
{code, _} when code in 200..299 ->
Hex.Shell.info("")
Hex.Shell.info("Published at #{Hex.Utils.hex_package_url(meta[:name], meta[:version])}")
Hex.Shell.info("\nPublished at #{Hex.Utils.hex_package_url(meta[:name], meta[:version])}")
Hex.Shell.info("Don't forget to upload your documentation with `mix hex.docs`")
{code, body} ->
Hex.Shell.error("Pushing #{meta[:name]} v#{meta[:version]} failed")
Hex.Shell.error("\nPushing #{meta[:name]} v#{meta[:version]} failed")
Hex.Utils.print_error_result(code, body)
end
end
@@ -246,7 +245,7 @@ defmodule Mix.Tasks.Hex.Publish do
include = for {app, req, opts} <- include, into: %{} do
name = opts[:hex] || app
{name, %{app: app, requirement: req, optional: opts[:optional]}}
{name, %{app: app, requirement: req, optional: opts[:optional] || false}}
end
exclude = for {app, _req, _opts} <- exclude, do: app
{include, exclude}
View
@@ -1,14 +1,14 @@
%{"bcrypt": {:git, "git://github.com/opscode/erlang-bcrypt.git", "7515e80a5e16f62aef149709f6cc09995dd480be", []},
%{"bcrypt": {:git, "https://github.com/opscode/erlang-bcrypt.git", "7515e80a5e16f62aef149709f6cc09995dd480be", []},
"cowboy": {:hex, :cowboy, "1.0.0"},
"cowlib": {:hex, :cowlib, "1.0.1"},
"decimal": {:hex, :decimal, "1.1.0"},
"earmark": {:hex, :earmark, "0.1.15"},
"ecto": {:git, "git://github.com/elixir-lang/ecto.git", "df464c6e1a4f1f3eff5f8ad5078e01b3f90f47af", []},
"ecto": {:git, "https://github.com/elixir-lang/ecto.git", "df464c6e1a4f1f3eff5f8ad5078e01b3f90f47af", []},
"envy": {:git, "git://github.com/manderson26/envy.git", "e6ba39664a1016ed309ea44269247943de2eb16b", [branch: "master"]},
"gen_smtp": {:hex, :gen_smtp, "0.9.0"},
"hex_web": {:git, "git://github.com/hexpm/hex_web.git", "57851ba31a477de6ed6efe3596aa09050c2bb81f", []},
"hex_web": {:git, "https://github.com/hexpm/hex_web.git", "57851ba31a477de6ed6efe3596aa09050c2bb81f", []},
"ibrowse": {:git, "git://github.com/opscode/ibrowse", "8f3f6a3a30730b193cc340a8885a960586dc98de", [tag: "v4.0.1.1"]},
"mini_s3": {:git, "git://github.com/ericmj/mini_s3.git", "700386bc8c3a804af57380c0fd09a02325142c9b", [branch: "hex-fixes"]},
"mini_s3": {:git, "https://github.com/ericmj/mini_s3.git", "700386bc8c3a804af57380c0fd09a02325142c9b", [branch: "hex-fixes"]},
"plug": {:hex, :plug, "0.11.3"},
"poison": {:hex, :poison, "1.4.0"},
"poolboy": {:hex, :poolboy, "1.5.1"},
@@ -4,7 +4,7 @@ defmodule Hex.RegistryTest do
test "stat" do
Hex.Registry.start!(registry_path: tmp_path("registry.ets"))
assert Hex.Registry.stat == {13, 34}
assert Hex.Registry.stat == {14, 35}
end
test "install info output once" do
@@ -103,4 +103,9 @@ defmodule Hex.ResolverTest do
deps = []
assert Dict.equal? [], resolve(deps, locked)
end
test "optional" do
deps = [ex_doc: nil, has_optional: nil]
assert Dict.equal? locked([ex_doc: "0.0.2", has_optional: "0.1.0"]), resolve(deps)
end
end
View
@@ -177,6 +177,8 @@ defmodule HexTest.Case do
{:only_doc, "0.1.0", [{:ex_doc, nil, true}]},
{:has_optional, "0.1.0", [{:ex_doc, "~> 0.0.1", true}]},
{:package_name, "0.1.0", []},
{:depend_name, "0.2.0", [{:package_name, nil, false, :app_name}]} ]
end

0 comments on commit bab7f2f

Please sign in to comment.