wrap: Re-set the console mode after calling git

`git submodule update --recursive` calls git clone recursively, and on
Windows it will undo the console mode we set in mlog and cause ANSI
colors to stop working. We could set it again only when we call that,
but we will definitely miss other instances where this could happen
in the future and regress.
This commit is contained in:
Nirbheek Chauhan 2020-01-22 20:04:41 +05:30 committed by Xavier Claessens
parent e962147d8a
commit 06dddf2ef0
1 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import urllib.request
import urllib.error
import urllib.parse
import os
import platform
import hashlib
import shutil
import tempfile
@ -53,6 +54,11 @@ def git(cmd: T.List[str], workingdir: str, **kwargs) -> subprocess.CompletedProc
# Redirect stdin to DEVNULL otherwise git messes up the
# console and ANSI colors stop working on Windows.
stdin=subprocess.DEVNULL, **kwargs)
# Sometimes git calls git recursively, such as `git submodule update
# --recursive` which will be without the above workaround, so set the
# console mode again just in case.
if platform.system().lower() == 'windows':
mlog._windows_ansi()
return pc
def quiet_git(cmd: T.List[str], workingdir: str) -> T.Tuple[bool, str]: