From 284cdb60b01599c387ff57b9adb70ced9a2a2fe9 Mon Sep 17 00:00:00 2001 From: Bas van der Vlies Date: Tue, 6 Aug 2024 13:37:56 +0200 Subject: [PATCH] git promise type must just continue if we have unicode error closes https://github.com/cfengine/modules/issues/99 --- promise-types/git/git.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/promise-types/git/git.py b/promise-types/git/git.py index 0a6fecc..1ccab38 100644 --- a/promise-types/git/git.py +++ b/promise-types/git/git.py @@ -236,16 +236,21 @@ def evaluate_promise(self, promiser: str, attributes: Dict, metadata: Dict): def _git(self, model: object, args: List[str], cwd: Optional[str] = None) -> str: self.log_verbose("Run: {cmd}".format(cmd=" ".join(args))) - output = ( - subprocess.check_output( - args, - env=self._git_envvars(model), - cwd=cwd, - stderr=subprocess.PIPE, + try: + output = ( + subprocess.check_output( + args, + env=self._git_envvars(model), + cwd=cwd, + stderr=subprocess.PIPE, + ) + .strip() + .decode("utf-8") ) - .strip() - .decode("utf-8") - ) + except UnicodeDecodeError: + output = "Could not decode output, just continue" + pass + output != "" and self.log_verbose(output) return output