Commit bb9721f
More robust git version parsing (#15019)
When GIT_TRACE=1 is set in the env, `mix deps.get` fails with an
unexpected `FunctionClauseError` due to `git --version`'s output
including trace output from git itself:
```
λ GIT_TRACE=1 mix deps.get
* Getting ariel (git@github.com:foo/bar.git - main)
22:17:06.786357 git.c:476 trace: built-in: git init --quiet
22:17:06.798692 git.c:476 trace: built-in: git remote add origin git@github.com:foo/bar.git
22:17:06.804333 git.c:476 trace: built-in: git config remote.origin.url git@github.com:foo/bar.git
** (FunctionClauseError) no function clause matching in Mix.SCM.Git.parse_version/1
The following arguments were given to Mix.SCM.Git.parse_version/1:
# 1
"22:17:06.809548 git.c:476 trace: built-in: git version\ngit version 2.50.1\n"
Attempted function clauses (showing 1 out of 1):
defp parse_version(<<"git version ", version::binary>>)
(mix 1.18.4) lib/mix/scm/git.ex:426: Mix.SCM.Git.parse_version/1
(mix 1.18.4) lib/mix/scm/git.ex:419: Mix.SCM.Git.git_version/0
(mix 1.18.4) lib/mix/scm/git.ex:132: Mix.SCM.Git.checkout/2
(elixir 1.18.4) lib/file.ex:1665: File.cd!/2
(mix 1.18.4) lib/mix/dep/fetcher.ex:68: Mix.Dep.Fetcher.do_fetch/3
(mix 1.18.4) lib/mix/dep/converger.ex:238: Mix.Dep.Converger.all/9
(mix 1.18.4) lib/mix/dep/converger.ex:170: Mix.Dep.Converger.init_all/8
(mix 1.18.4) lib/mix/dep/converger.ex:110: Mix.Dep.Converger.all/4
```
This patch updates `git_version` to handle trace noise by running
parse on the final output line of `git --version`.
New `deps.git_test` added to exercise the `GIT_TRACE` condition.
* Update lib/mix/test/mix/tasks/deps.git_test.exs
---------
Co-authored-by: José Valim <jose.valim@gmail.com>1 parent 68207c0 commit bb9721f
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
430 | 438 | | |
431 | 439 | | |
432 | 440 | | |
| |||
435 | 443 | | |
436 | 444 | | |
437 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
438 | 450 | | |
439 | 451 | | |
440 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
| |||
0 commit comments