Skip to content

Commit df56460

Browse files
authored
Fix mix tests on older git versions (#10815)
The configuration init.defaultBranch is a recent addition to git. When it's not available the tests will fail because the wrong branch is created.
1 parent 4f533cf commit df56460

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/mix/test/test_helper.exs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ end)
225225
## Generate Git repo fixtures
226226
System.cmd("git", ~w[config --global user.email "[email protected]"])
227227
System.cmd("git", ~w[config --global user.name "mix-repo"])
228-
System.cmd("git", ~w[config --global init.defaultBranch main])
229228

230229
# Git repo
231230
target = Path.expand("fixtures/git_repo", __DIR__)
@@ -242,9 +241,8 @@ unless File.dir?(target) do
242241
System.cmd("git", ~w[init])
243242
System.cmd("git", ~w[add .])
244243
System.cmd("git", ~w[commit -m "bad"])
245-
System.cmd("git", ~w[checkout -q -b development])
246-
System.cmd("git", ~w[symbolic-ref HEAD refs/heads/development])
247-
System.cmd("git", ~w[branch -d main])
244+
System.cmd("git", ~w[checkout -q -b main])
245+
System.cmd("git", ~w[symbolic-ref HEAD refs/heads/main])
248246
end)
249247

250248
File.write!(Path.join(target, "mix.exs"), """
@@ -334,6 +332,8 @@ unless File.dir?(target) do
334332
System.cmd("git", ~w[init])
335333
System.cmd("git", ~w[add .])
336334
System.cmd("git", ~w[commit -m without-dep])
335+
System.cmd("git", ~w[checkout -q -b main])
336+
System.cmd("git", ~w[symbolic-ref HEAD refs/heads/main])
337337
end)
338338

339339
File.write!(Path.join(target, "mix.exs"), """
@@ -387,6 +387,8 @@ unless File.dir?(target) do
387387
System.cmd("git", ~w[init])
388388
System.cmd("git", ~w[add .])
389389
System.cmd("git", ~w[commit -m "ok"])
390+
System.cmd("git", ~w[checkout -q -b main])
391+
System.cmd("git", ~w[symbolic-ref HEAD refs/heads/main])
390392
end)
391393
end
392394

0 commit comments

Comments
 (0)