Skip to content

Commit 14e1d41

Browse files
author
José Valim
committed
Do not tag mix exceptions if in root project
1 parent 1592557 commit 14e1d41

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

lib/mix/lib/mix.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ defmodule Mix do
9595

9696
defp mix_info do
9797
case Mix.ProjectStack.peek do
98-
{name, config, _file} ->
98+
%{name: name, config: config, pos: pos} when pos > 0 ->
9999
if app = config[:app] do
100100
{:app, app}
101101
else

lib/mix/lib/mix/cli.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ defmodule Mix.CLI do
104104
(env = Mix.Project.config[:preferred_cli_env][task]) do
105105
Mix.env(env)
106106
if project = Mix.Project.pop do
107-
{project, _config, file} = project
108-
Mix.Project.push project, file
107+
%{name: name, file: file} = project
108+
Mix.Project.push name, file
109109
end
110110
end
111111
end

lib/mix/lib/mix/project.ex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ defmodule Mix.Project do
8787
"""
8888
def get do
8989
case Mix.ProjectStack.peek do
90-
{name, _config, _file} -> name
90+
%{name: name} -> name
9191
_ -> nil
9292
end
9393
end
@@ -122,7 +122,7 @@ defmodule Mix.Project do
122122
"""
123123
def config do
124124
case Mix.ProjectStack.peek do
125-
{_name, config, _file} -> config
125+
%{config: config} -> config
126126
_ -> default_config
127127
end
128128
end
@@ -139,12 +139,13 @@ defmodule Mix.Project do
139139
def config_files do
140140
[Mix.Dep.Lock.manifest] ++
141141
case Mix.ProjectStack.peek do
142-
{_name, config, file} ->
143-
configs = (config[:config_path] || "config/config.exs")
144-
|> Path.dirname
145-
|> Path.join("*.*")
146-
|> Path.wildcard
147-
|> Enum.reject(&String.starts_with?(Path.basename(&1), "."))
142+
%{config: config, file: file} ->
143+
configs =
144+
(config[:config_path] || "config/config.exs")
145+
|> Path.dirname
146+
|> Path.join("*.*")
147+
|> Path.wildcard
148+
|> Enum.reject(&String.starts_with?(Path.basename(&1), "."))
148149
[file|configs]
149150
_ ->
150151
[]

lib/mix/lib/mix/project_stack.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Mix.ProjectStack do
2323
io_done? = stack == []
2424

2525
config = Keyword.merge(config, state.post_config)
26-
project = %{name: module, config: config, file: file,
26+
project = %{name: module, config: config, file: file, pos: length(stack),
2727
recursing?: false, io_done: io_done?, tasks: HashSet.new}
2828

2929
cond do
@@ -39,7 +39,7 @@ defmodule Mix.ProjectStack do
3939
def pop do
4040
get_and_update fn %{stack: stack} = state ->
4141
case stack do
42-
[h|t] -> {project_to_tuple(h), %{state | stack: t}}
42+
[h|t] -> {take(h), %{state | stack: t}}
4343
[] -> {nil, state}
4444
end
4545
end
@@ -49,7 +49,7 @@ defmodule Mix.ProjectStack do
4949
def peek do
5050
get fn %{stack: stack} ->
5151
case stack do
52-
[h|_] -> project_to_tuple(h)
52+
[h|_] -> take(h)
5353
[] -> nil
5454
end
5555
end
@@ -147,8 +147,8 @@ defmodule Mix.ProjectStack do
147147
end)
148148
end
149149

150-
defp project_to_tuple(%{name: name, config: config, file: file}) do
151-
{name, config, file}
150+
defp take(h) do
151+
Map.take(h, [:name, :config, :file, :pos])
152152
end
153153

154154
defp has_app?(%{config: config}) do

lib/mix/test/mix/project_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule Mix.ProjectTest do
1414
Mix.Project.push(SampleProject, "sample")
1515
assert Mix.Project.get == SampleProject
1616

17-
assert {SampleProject, _config, "sample"} = Mix.Project.pop
17+
assert %{name: SampleProject, config: _, file: "sample"} = Mix.Project.pop
1818
assert nil = Mix.Project.pop
1919
end
2020

@@ -29,8 +29,8 @@ defmodule Mix.ProjectTest do
2929
test "allows nil projects to be pushed twice" do
3030
Mix.Project.push nil
3131
Mix.Project.push nil
32-
assert is_tuple Mix.Project.pop
33-
assert is_tuple Mix.Project.pop
32+
assert is_map Mix.Project.pop
33+
assert is_map Mix.Project.pop
3434
assert nil? Mix.Project.pop
3535
end
3636

lib/mix/test/mix/tasks/deps.git_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ defmodule Mix.Tasks.DepsGitTest do
288288
end
289289

290290
defp refresh(post_config) do
291-
{current, _config, file} = Mix.Project.pop
291+
%{name: name, file: file} = Mix.Project.pop
292292
Mix.ProjectStack.post_config(post_config)
293-
Mix.Project.push(current, file)
293+
Mix.Project.push(name, file)
294294
end
295295

296296
defp get_git_repo_revs do

lib/mix/test/test_helper.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ defmodule MixTest.Case do
105105
ensure_touched(file, File.stat!(file).mtime)
106106
end
107107

108-
defp ensure_touched(file, current) do
108+
def ensure_touched(file, current) do
109109
File.touch!(file)
110110
unless File.stat!(file).mtime > current do
111111
ensure_touched(file, current)

0 commit comments

Comments
 (0)