@@ -164,7 +164,7 @@ defmodule Mix.SCM.Git do
164
164
defp sparse_toggle ( opts ) do
165
165
cond do
166
166
sparse = opts [ :sparse ] ->
167
- sparse_check ( git_version ( ) )
167
+ check_sparse_support ( git_version ( ) )
168
168
git! ( [ "--git-dir=.git" , "config" , "core.sparsecheckout" , "true" ] )
169
169
File . mkdir_p! ( ".git/info" )
170
170
File . write! ( ".git/info/sparse-checkout" , sparse )
@@ -180,13 +180,15 @@ defmodule Mix.SCM.Git do
180
180
end
181
181
end
182
182
183
- defp sparse_check ( version ) do
184
- unless { 1 , 7 , 4 } <= version do
185
- version = version |> Tuple . to_list ( ) |> Enum . join ( "." )
183
+ defp check_sparse_support ( version ) do
184
+ ensure_feature_compatibility ( version , { 1 , 7 , 4 } , "sparse checkout" )
185
+ end
186
186
187
+ defp ensure_feature_compatibility ( version , required_version , feature ) do
188
+ unless required_version <= version do
187
189
Mix . raise (
188
- "Git >= 1.7.4 is required to use sparse checkout . " <>
189
- "You are running version #{ version } "
190
+ "Git >= #{ format_version ( required_version ) } is required to use #{ feature } . " <>
191
+ "You are running version #{ format_version ( version ) } "
190
192
)
191
193
end
192
194
end
@@ -354,6 +356,10 @@ defmodule Mix.SCM.Git do
354
356
|> List . to_tuple ( )
355
357
end
356
358
359
+ defp format_version ( version ) do
360
+ version |> Tuple . to_list ( ) |> Enum . join ( "." )
361
+ end
362
+
357
363
defp to_integer ( string ) do
358
364
{ int , _ } = Integer . parse ( string )
359
365
int
0 commit comments