Skip to content

Commit de07fb9

Browse files
committed
Validates that a hex package does not include a dpendncy that is in an umbrella.
1 parent 1c613cc commit de07fb9

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

lib/mix/tasks/hex.build.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ defmodule Mix.Tasks.Hex.Build do
303303
end
304304
end
305305

306-
@scm_keys [:git, :github, :path]
306+
@scm_keys [:git, :github, :path, :in_umbrella]
307307

308308
defp package_dep?({_app, _req, opts}) do
309309
keys = Keyword.keys(opts)

test/mix/tasks/hex.build_test.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,26 @@ defmodule Mix.Tasks.Hex.BuildTest do
401401
purge([ReleaseIncludeReservedFile.MixProject])
402402
end
403403

404+
test "errors with umbrella deps" do
405+
Process.put(:hex_test_app_name, :includes_umbrella_deps)
406+
Mix.Project.push(ReleaseInUmbrellaDeps.MixProject)
407+
408+
in_tmp(fn ->
409+
Hex.State.put(:cache_home, tmp_path())
410+
411+
File.write!("myfile.txt", "hello")
412+
File.chmod!("myfile.txt", 0o100644)
413+
414+
error_msg = "Stopping package build due to errors.\nDependencies excluded from the package (only Hex packages can be dependencies): ecto"
415+
416+
assert_raise Mix.Error, error_msg, fn ->
417+
Mix.Tasks.Hex.Build.run([])
418+
end
419+
end)
420+
after
421+
purge([ReleaseInUmbrellaDeps.MixProject])
422+
end
423+
404424
test "build and unpack" do
405425
Process.put(:hex_test_app_name, :build_and_unpack)
406426
Mix.Project.push(Sample.MixProject)

test/support/case.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ defmodule HexTest.Case do
221221
{:hexpm, :phoenix_live_reload, "1.0.3", [phoenix: "~> 0.16 or ~> 1.0"]},
222222
{:hexpm, :postgrex, "0.2.0", [ex_doc: "0.0.1"]},
223223
{:hexpm, :postgrex, "0.2.1", [ex_doc: "~> 0.1.0"]},
224+
{:hexpm, :umb, "0.2.1", [ex_doc: "~> 0.1.0"]},
224225
{:repo2, :hexpm_deps, "0.1.0", [{:poison, ">= 0.0.0", false, :poison, :hexpm}]},
225226
{:repo2, :poison, "2.0.0", []},
226227
{:repo2, :repo2_deps, "0.1.0", [poison: ">= 0.0.0"]}

test/support/hexpm.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ defmodule HexTest.Hexpm do
262262
|> Map.put_new(:app, name)
263263
|> Map.put_new(:build_tools, ["mix"])
264264
|> Map.put_new(:files, ["mix.exs"])
265-
265+
266266
deps = inspect(deps, pretty: true)
267267
module = String.capitalize(name)
268268
mix_exs = :io_lib.format(@mix_exs_template, [module, name, version, deps])

test/support/release_samples.ex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,22 @@ defmodule ReleaseAppFalseDep.MixProject do
354354
]
355355
end
356356
end
357+
358+
defmodule ReleaseInUmbrellaDeps.MixProject do
359+
def project do
360+
[
361+
app: Process.get(:hex_test_app_name) || raise("missing app name"),
362+
description: "includes umbrella",
363+
version: "0.2.1",
364+
deps: [
365+
{:ecto, "3.3.2", in_umbrella: true},
366+
{:postgrex, "0.2.1"}
367+
],
368+
package: [
369+
licenses: ["MIT"],
370+
files: ["myfile.txt"],
371+
links: %{"a" => "http://a"}
372+
]
373+
]
374+
end
375+
end

0 commit comments

Comments
 (0)