summaryrefslogtreecommitdiff
path: root/user/elixir/tests2.patch
blob: f44b028df2f3ce002f7cd5ff098de055b61cae53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
From 3d1c1b4e2396e9891d38d00185889bd4a421db1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@dashbit.co>
Date: Sat, 13 Jun 2020 10:01:10 +0200
Subject: [PATCH] Use global gitconfig instead of individual options on
 commands

Closes #10098.
---
 lib/mix/lib/mix/scm/git.ex              |  7 ++--
 lib/mix/test/mix/tasks/escript_test.exs |  2 +-
 lib/mix/test/test_helper.exs            | 45 +++++++++++++------------
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/lib/mix/lib/mix/scm/git.ex b/lib/mix/lib/mix/scm/git.ex
index 2c07b9515f..6f66202052 100644
--- a/lib/mix/lib/mix/scm/git.ex
+++ b/lib/mix/lib/mix/scm/git.ex
@@ -251,8 +251,11 @@ defmodule Mix.SCM.Git do
     opts = cmd_opts(into: into, stderr_to_stdout: true)
 
     case System.cmd("git", args, opts) do
-      {response, 0} -> response
-      {_, _} -> Mix.raise("Command \"git #{Enum.join(args, " ")}\" failed")
+      {response, 0} ->
+        response
+
+      {response, _} ->
+        Mix.raise("Command \"git #{Enum.join(args, " ")}\" failed with reason: #{response}")
     end
   end
 
diff --git a/lib/mix/test/mix/tasks/escript_test.exs b/lib/mix/test/mix/tasks/escript_test.exs
index f8f1baaf15..5d9eb8390a 100644
--- a/lib/mix/test/mix/tasks/escript_test.exs
+++ b/lib/mix/test/mix/tasks/escript_test.exs
@@ -351,7 +351,7 @@ defmodule Mix.Tasks.EscriptTest do
       """)
 
       System.cmd("git", ~w[add .])
-      System.cmd("git", ~w[commit --no-gpg-sign -m "ok"])
+      System.cmd("git", ~w[commit -m "ok"])
 
       send(self(), {:mix_shell_input, :yes?, true})
       Mix.Tasks.Escript.Install.run(["git", File.cwd!()])
diff --git a/lib/mix/test/test_helper.exs b/lib/mix/test/test_helper.exs
index 88c6434816..1dec2be0b0 100644
--- a/lib/mix/test/test_helper.exs
+++ b/lib/mix/test/test_helper.exs
@@ -182,18 +182,23 @@ defmodule MixTest.Case do
   end
 end
 
-## Set up Mix home with Rebar
+## Set up globals
 
-home = MixTest.Case.tmp_path(".mix")
+home = MixTest.Case.tmp_path(".home")
 File.mkdir_p!(home)
-System.put_env("MIX_HOME", home)
+System.put_env("HOME", home)
+
+mix = MixTest.Case.tmp_path(".mix")
+File.mkdir_p!(mix)
+System.put_env("MIX_HOME", mix)
+
 System.delete_env("XDG_DATA_HOME")
 System.delete_env("XDG_CONFIG_HOME")
 
 rebar = System.get_env("REBAR") || Path.expand("fixtures/rebar", __DIR__)
-File.cp!(rebar, Path.join(home, "rebar"))
+File.cp!(rebar, Path.join(mix, "rebar"))
 rebar = System.get_env("REBAR3") || Path.expand("fixtures/rebar3", __DIR__)
-File.cp!(rebar, Path.join(home, "rebar3"))
+File.cp!(rebar, Path.join(mix, "rebar3"))
 
 ## Copy fixtures to tmp
 
@@ -207,6 +212,8 @@ Enum.each(fixtures, fn fixture ->
 end)
 
 ## Generate Git repo fixtures
+System.cmd("git", ~w[config --global user.email "mix@example.com"])
+System.cmd("git", ~w[config --global user.name "mix-repo"])
 
 # Git repo
 target = Path.expand("fixtures/git_repo", __DIR__)
@@ -220,11 +227,9 @@ unless File.dir?(target) do
   """)
 
   File.cd!(target, fn ->
-    System.cmd("git", ~w[-c core.hooksPath='' init])
-    System.cmd("git", ~w[config user.email "mix@example.com"])
-    System.cmd("git", ~w[config user.name "mix-repo"])
+    System.cmd("git", ~w[init])
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m "bad"])
+    System.cmd("git", ~w[commit -m "bad"])
   end)
 
   File.write!(Path.join(target, "mix.exs"), """
@@ -243,8 +248,8 @@ unless File.dir?(target) do
 
   File.cd!(target, fn ->
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m "ok"])
-    System.cmd("git", ~w[tag --no-sign without_module])
+    System.cmd("git", ~w[commit -m "ok"])
+    System.cmd("git", ~w[tag without_module])
   end)
 
   File.write!(Path.join(target, "lib/git_repo.ex"), """
@@ -285,8 +290,8 @@ unless File.dir?(target) do
 
   File.cd!(target, fn ->
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m "lib"])
-    System.cmd("git", ~w[tag --no-sign with_module])
+    System.cmd("git", ~w[commit -m "lib"])
+    System.cmd("git", ~w[tag with_module])
   end)
 end
 
@@ -311,11 +316,9 @@ unless File.dir?(target) do
   """)
 
   File.cd!(target, fn ->
-    System.cmd("git", ~w[-c core.hooksPath='' init])
-    System.cmd("git", ~w[config user.email "mix@example.com"])
-    System.cmd("git", ~w[config user.name "mix-repo"])
+    System.cmd("git", ~w[init])
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m without-dep])
+    System.cmd("git", ~w[commit -m without-dep])
   end)
 
   File.write!(Path.join(target, "mix.exs"), """
@@ -342,7 +345,7 @@ unless File.dir?(target) do
 
   File.cd!(target, fn ->
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m with-dep])
+    System.cmd("git", ~w[commit -m with-dep])
   end)
 end
 
@@ -366,11 +369,9 @@ unless File.dir?(target) do
   """)
 
   File.cd!(target, fn ->
-    System.cmd("git", ~w[-c core.hooksPath='' init])
-    System.cmd("git", ~w[config user.email "mix@example.com"])
-    System.cmd("git", ~w[config user.name "mix-repo"])
+    System.cmd("git", ~w[init])
     System.cmd("git", ~w[add .])
-    System.cmd("git", ~w[commit --no-gpg-sign -m "ok"])
+    System.cmd("git", ~w[commit -m "ok"])
   end)
 end