2
2
import argparse
3
3
import contextlib
4
4
import datetime
5
+ import distutils .version
5
6
import hashlib
6
7
import os
7
8
import re
@@ -331,6 +332,7 @@ def __init__(self):
331
332
self .use_locked_deps = ''
332
333
self .use_vendored_sources = ''
333
334
self .verbose = False
335
+ self .git_version = None
334
336
335
337
def download_stage0 (self ):
336
338
"""Fetch the build system for Rust, written in Rust
@@ -743,15 +745,13 @@ def update_submodule(self, module, checked_out, recorded_submodules):
743
745
744
746
run (["git" , "submodule" , "-q" , "sync" , module ],
745
747
cwd = self .rust_root , verbose = self .verbose )
746
- try :
747
- run (["git" , "submodule" , "update" ,
748
- "--init" , "--recursive" , "--progress" , module ],
749
- cwd = self .rust_root , verbose = self .verbose , exception = True )
750
- except RuntimeError :
751
- # Some versions of git don't support --progress.
752
- run (["git" , "submodule" , "update" ,
753
- "--init" , "--recursive" , module ],
754
- cwd = self .rust_root , verbose = self .verbose )
748
+
749
+ update_args = ["git" , "submodule" , "update" , "--init" , "--recursive" ]
750
+ if self .git_version >= distutils .version .LooseVersion ("2.11.0" ):
751
+ update_args .append ("--progress" )
752
+ update_args .append (module )
753
+ run (update_args , cwd = self .rust_root , verbose = self .verbose , exception = True )
754
+
755
755
run (["git" , "reset" , "-q" , "--hard" ],
756
756
cwd = module_path , verbose = self .verbose )
757
757
run (["git" , "clean" , "-qdfx" ],
@@ -763,9 +763,13 @@ def update_submodules(self):
763
763
self .get_toml ('submodules' ) == "false" :
764
764
return
765
765
766
- # check the existence of 'git' command
766
+ default_encoding = sys .getdefaultencoding ()
767
+
768
+ # check the existence and version of 'git' command
767
769
try :
768
- subprocess .check_output (['git' , '--version' ])
770
+ git_version_output = subprocess .check_output (['git' , '--version' ])
771
+ git_version_str = git_version_output .strip ().split ()[2 ].decode (default_encoding )
772
+ self .git_version = distutils .version .LooseVersion (git_version_str )
769
773
except (subprocess .CalledProcessError , OSError ):
770
774
print ("error: `git` is not found, please make sure it's installed and in the path." )
771
775
sys .exit (1 )
0 commit comments