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 | |
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')
-rw-r--r-- | mesonbuild/mesonlib.py | 16 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 19 |
2 files changed, 17 insertions, 18 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 diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 26f3d4a..969c82d 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -30,7 +30,7 @@ import typing as T from pathlib import Path from . import WrapMode from .. import coredata -from ..mesonlib import git, GIT, ProgressBar, MesonException +from ..mesonlib import verbose_git, quiet_git, GIT, ProgressBar, MesonException if T.TYPE_CHECKING: import http.client @@ -49,23 +49,6 @@ REQ_TIMEOUT = 600.0 SSL_WARNING_PRINTED = False WHITELIST_SUBDOMAIN = 'wrapdb.mesonbuild.com' -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 whitelist_wrapdb(urlstr: str) -> urllib.parse.ParseResult: """ raises WrapException if not whitelisted subdomain """ url = urllib.parse.urlparse(urlstr) |