Skip to content

Commit 4637b57

Browse files
committed
Fix handling of raw rebar deps
1 parent 207c626 commit 4637b57

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

lib/mix/lib/mix/rebar.ex

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,30 @@ defmodule Mix.Rebar do
8888
{ app, compile_req(req), [path: Path.join(deps_dir, app)] }
8989
end
9090

91-
defp parse_dep({ app, req, source }, _deps_dir) do
91+
defp parse_dep({ app, req, source }, deps_dir) do
92+
parse_dep({ app, req, source, [] }, deps_dir)
93+
end
94+
95+
defp parse_dep({ app, req, source, opts }, _deps_dir) do
9296
[ scm, url | source ] = tuple_to_list(source)
97+
mix_opts = [{ scm, to_string(url) }]
9398

94-
{ ref, source } = case source do
95-
[""|s] -> { [branch: "HEAD"], s }
96-
[{ :branch, branch }|s] -> { [branch: to_string(branch)], s }
97-
[{ :tag, tag }|s] -> { [tag: to_string(tag)], s }
98-
[ref|s] -> { [ref: to_string(ref)], s }
99-
_ -> { [], [] }
100-
end
99+
ref =
100+
case source do
101+
[""|_] -> [branch: "HEAD"]
102+
[{ :branch, branch }|_] -> [branch: to_string(branch)]
103+
[{ :tag, tag }|_] -> [tag: to_string(tag)]
104+
[ref|_] -> [ref: to_string(ref)]
105+
_ -> []
106+
end
107+
108+
mix_opts = mix_opts ++ ref
101109

102-
raw = case source do
103-
[[:raw]|_] -> [app: false]
104-
[[raw: true]|_] -> [app: false]
105-
_ -> []
110+
if :proplists.get_value(:raw, opts, false) do
111+
mix_opts = mix_opts ++ [compile: false]
106112
end
107113

108-
opts = [{ scm, to_string(url) }] ++ ref ++ raw
109-
{ app, compile_req(req), opts }
114+
{ app, compile_req(req), mix_opts }
110115
end
111116

112117
defp parse_dep(app, deps_dir) do

lib/mix/test/mix/rebar_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ defmodule Mix.RebarTest do
5252
end
5353

5454
test "parse rebar dependencies" do
55+
config = [deps: [{ :git_rebar, '.*', }]]
56+
assert [{ :git_rebar, ~r".*", [path: "deps/git_rebar"] }] ==
57+
Mix.Rebar.deps(config)
58+
59+
config = [deps: [{ :git_rebar, '.*', }], deps_dir: "other_dir"]
60+
assert [{ :git_rebar, ~r".*", [path: "other_dir/git_rebar"] }] ==
61+
Mix.Rebar.deps(config)
62+
63+
config = [deps: [{ :git_rebar, '0.1..*', { :git, '../../test/fixtures/git_rebar', :master } }]]
64+
assert [{ :git_rebar, ~r"0.1..*", [git: "../../test/fixtures/git_rebar", ref: "master"] }] ==
65+
Mix.Rebar.deps(config)
66+
67+
config = [deps: [{ :git_rebar, '0.1..*', { :git, '../../test/fixtures/git_rebar' }, [:raw] }]]
68+
assert [{ :git_rebar, ~r"0.1..*", [git: "../../test/fixtures/git_rebar", compile: false] }] ==
69+
Mix.Rebar.deps(config)
70+
end
71+
72+
test "parse rebar dependencies from rebar.config" do
5573
Mix.Project.push(RebarAsDep)
5674

5775
deps = Mix.Deps.loaded

0 commit comments

Comments
 (0)