Skip to content

Commit 59dc733

Browse files
committed
Merge pull request #2138 from elixir-lang/mix-old-git
Support older gits in mix
2 parents b18ddd4 + 0c9d5f1 commit 59dc733

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/mix/lib/mix/scm/git.ex

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ defmodule Mix.SCM.Git do
7979
location = opts[:git]
8080
update_origin(location)
8181

82-
command = "git fetch --force --progress"
82+
command = "git fetch --force"
83+
84+
if { 1, 7, 1 } <= git_version() do
85+
command = command <> " --progress"
86+
end
87+
8388
if opts[:tag] do
8489
command = command <> " --tags"
8590
end
@@ -146,4 +151,20 @@ defmodule Mix.SCM.Git do
146151
end
147152
true
148153
end
154+
155+
defp git_version do
156+
case :application.get_env(:mix, :git_version) do
157+
{ :ok, version } ->
158+
version
159+
:undefined ->
160+
"git version " <> version = String.strip System.cmd("git --version")
161+
version = String.split(version, ".")
162+
|> Enum.take(3)
163+
|> Enum.map(&binary_to_integer(&1))
164+
|> list_to_tuple
165+
166+
:application.set_env(:mix, :git_version, version)
167+
version
168+
end
169+
end
149170
end

0 commit comments

Comments
 (0)