diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-09-08 10:30:54 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-09-10 11:39:30 -0400 |
commit | 276c3fcb5a1c95205b3f6fa5811300db61ef2dbd (patch) | |
tree | 177a7b6e366d2b37422f81a1e990772128be0c88 /mesonbuild/mesonlib.py | |
parent | 8a9baab4d3ac402645e719fb6e9180383ac5d3e8 (diff) | |
download | meson-276c3fcb5a1c95205b3f6fa5811300db61ef2dbd.zip meson-276c3fcb5a1c95205b3f6fa5811300db61ef2dbd.tar.gz meson-276c3fcb5a1c95205b3f6fa5811300db61ef2dbd.tar.bz2 |
Move verbose_git() and quiet_git() to mesonlib
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index cf43131..540d718 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -88,6 +88,22 @@ def git(cmd: T.List[str], workingdir: str, **kwargs: T.Any) -> subprocess.Comple mlog.setup_console() return pc +def quiet_git(cmd: T.List[str], workingdir: str) -> T.Tuple[bool, str]: + if not GIT: + return False, 'Git program not found.' + pc = git(cmd, workingdir, universal_newlines=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if pc.returncode != 0: + return False, pc.stderr + return True, pc.stdout + +def verbose_git(cmd: T.List[str], workingdir: str, check: bool = False) -> bool: + if not GIT: + return False + try: + return git(cmd, workingdir, check=check).returncode == 0 + except subprocess.CalledProcessError: + raise WrapException('Git command failed') def set_meson_command(mainfile: str) -> None: global python_command |