[stable-2.9] ansible-test - Continue if the git command returns an error (#61605)

* ansible-test - Contiune if the git command returns an error

* Just return stdout

* Use to_text() when displaying exception

* Add a message property to SubprocessError
(cherry picked from commit e218c98)

Co-authored-by: Sam Doran <sdoran@redhat.com>
pull/61675/head
Sam Doran 5 years ago committed by Toshio Kuratomi
parent e9310c1a44
commit dc5f369245

@ -8,7 +8,9 @@ from . import types as t
from .util import (
SubprocessError,
display,
raw_command,
to_text,
)
@ -124,4 +126,8 @@ class Git:
:type str_errors: str
:rtype: str
"""
return raw_command([self.git] + cmd, cwd=self.root, capture=True, str_errors=str_errors)[0]
try:
return raw_command([self.git] + cmd, cwd=self.root, capture=True, str_errors=str_errors)[0]
except SubprocessError as spe:
display.warning(to_text(spe.message))
return spe.stdout

@ -754,6 +754,7 @@ class SubprocessError(ApplicationError):
super(SubprocessError, self).__init__(message)
self.cmd = cmd
self.message = message
self.status = status
self.stdout = stdout
self.stderr = stderr

Loading…
Cancel
Save