about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-30 20:15:26 +0200
committerGitHub <noreply@github.com>2020-04-30 20:15:26 +0200
commit2770f820aa770080770df2b29c03113e14f5bdc8 (patch)
tree0778a12b70e34e59dea3484f391271264a8cc6a8 /src/bootstrap
parent5e53f80d6e72b7582239df39e26695c668a2c5e4 (diff)
parent7ac093fda9f458ac4c9d5bd52e44d1247627a3b6 (diff)
downloadrust-2770f820aa770080770df2b29c03113e14f5bdc8.tar.gz
rust-2770f820aa770080770df2b29c03113e14f5bdc8.zip
Rollup merge of #71559 - dillona:detect_git_progress_version, r=Mark-Simulacrum
Detect git version before attempting to use --progress

Otherwise each update is run twice and errors are printed

I've tested this with:
git version 2.8.2.windows.1 (Windows)
git version 2.26.2.266.ge870325ee8 (Linux built from source)
git version 2.17.1 (Linux)
git version 2.21.1 (Apple Git-122.3) (MacOS)

I've tested with Python 2.7 (Windows, Linux, MacOS), 3.6 (Linux), and 3.7 (MacOS)
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/bootstrap.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index d5efed61b54..2aa3f9c7ec0 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import, division, print_function
 import argparse
 import contextlib
 import datetime
+import distutils.version
 import hashlib
 import os
 import re
@@ -331,6 +332,7 @@ class RustBuild(object):
         self.use_locked_deps = ''
         self.use_vendored_sources = ''
         self.verbose = False
+        self.git_version = None
 
     def download_stage0(self):
         """Fetch the build system for Rust, written in Rust
@@ -743,15 +745,13 @@ class RustBuild(object):
 
         run(["git", "submodule", "-q", "sync", module],
             cwd=self.rust_root, verbose=self.verbose)
-        try:
-            run(["git", "submodule", "update",
-                 "--init", "--recursive", "--progress", module],
-                cwd=self.rust_root, verbose=self.verbose, exception=True)
-        except RuntimeError:
-            # Some versions of git don't support --progress.
-            run(["git", "submodule", "update",
-                 "--init", "--recursive", module],
-                cwd=self.rust_root, verbose=self.verbose)
+
+        update_args = ["git", "submodule", "update", "--init", "--recursive"]
+        if self.git_version >= distutils.version.LooseVersion("2.11.0"):
+            update_args.append("--progress")
+        update_args.append(module)
+        run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
+
         run(["git", "reset", "-q", "--hard"],
             cwd=module_path, verbose=self.verbose)
         run(["git", "clean", "-qdfx"],
@@ -763,9 +763,13 @@ class RustBuild(object):
                 self.get_toml('submodules') == "false":
             return
 
-        # check the existence of 'git' command
+        default_encoding = sys.getdefaultencoding()
+
+        # check the existence and version of 'git' command
         try:
-            subprocess.check_output(['git', '--version'])
+            git_version_output = subprocess.check_output(['git', '--version'])
+            git_version_str = git_version_output.strip().split()[2].decode(default_encoding)
+            self.git_version = distutils.version.LooseVersion(git_version_str)
         except (subprocess.CalledProcessError, OSError):
             print("error: `git` is not found, please make sure it's installed and in the path.")
             sys.exit(1)