From 8722047331917b2b31d7677bf90d264c12b62e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Thu, 30 May 2024 22:50:05 +0200 Subject: [PATCH] Ignore the stderr output when getting the parent tag --- TarSCM/helpers.py | 14 ++++++++------ TarSCM/scm/git.py | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/TarSCM/helpers.py b/TarSCM/helpers.py index 0254a97e..3e5a9243 100644 --- a/TarSCM/helpers.py +++ b/TarSCM/helpers.py @@ -25,7 +25,8 @@ def file_write_legacy(fname, string, *args): class Helpers(): - def run_cmd(self, cmd, cwd, interactive=False, raisesysexit=False): + def run_cmd(self, cmd, cwd, interactive=False, raisesysexit=False, + includeStderr=True): """ Execute the command cmd in the working directory cwd and check return value. If the command returns non-zero and raisesysexit is True raise a @@ -34,11 +35,12 @@ def run_cmd(self, cmd, cwd, interactive=False, raisesysexit=False): """ logging.debug("COMMAND: %s" % cmd) - proc = subprocess.Popen(cmd, - shell=False, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - cwd=cwd) + proc = subprocess.Popen( + cmd, + shell=False, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT if includeStderr else subprocess.DEVNULL, + cwd=cwd) output = '' if interactive: stdout_lines = [] diff --git a/TarSCM/scm/git.py b/TarSCM/scm/git.py index 87bdfdb6..3b659841 100644 --- a/TarSCM/scm/git.py +++ b/TarSCM/scm/git.py @@ -307,7 +307,8 @@ def _detect_parent_tag(self, args=None): cmd.append("--match=%s" % args['match_tag']) except KeyError: pass - rcode, output = self.helpers.run_cmd(cmd, self.clone_dir) + rcode, output = self.helpers.run_cmd(cmd, self.clone_dir, + includeStderr=False) if rcode == 0: # strip to remove newlines