[FIX] forwardport: error reporting when git command fails

- if stderr was empty or had been redirected to stdout, no useful
  information would be show, making debugging more complicated
- the fallback is the error itself, but since it's reraised odds are
  pretty high the caller will eventually log the error itself, so
  it's redundant

=> fallback to stdout if stderr is empty, and only log if either is
non-empty
This commit is contained in:
Xavier Morel 2022-10-19 07:51:03 +02:00
parent 6281c86d5e
commit 22c3406659

View File

@ -1146,7 +1146,8 @@ class Repo:
try:
return self._opener(args, **opts)
except subprocess.CalledProcessError as e:
_logger.error("git call error:%s", ('\n' + e.stderr.decode()) if e.stderr else e )
stream = e.stderr if e.stderr else e.stdout if e.stdout else ''
_logger.error("git call error%s%s", stream and ': ', stream)
raise
def stdout(self, flag=True):