[git-buildpackage] [PATCH 07/11] Command: strip newlines from stdout/err in error msg

Guido Günther agx at sigxcpu.org
Wed Apr 1 21:11:26 CEST 2015


On Tue, Mar 31, 2015 at 07:18:54PM +0300, Markus Lehtonen wrote:
> Strip extra linefeeds from stdout and stderr output (if captured) when
> generating the error message, so that the error message itself would not
> have any unwanted linefeeds.
> 
> Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
> ---
>  gbp/command_wrappers.py   | 6 ++++--
>  tests/test_PristineTar.py | 1 -
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
> index 0f6fc88..d66bfda 100644
> --- a/gbp/command_wrappers.py
> +++ b/gbp/command_wrappers.py
> @@ -105,8 +105,10 @@ class Command(object):
>          This allows to replace stdout, stderr and err_reason in
>          the self.run_error.
>          """
> -        return self.run_error.format(stdout=self.stdout,
> -                                     stderr=self.stderr,
> +        stdout = self.stdout.rstrip() if self.stdout else self.stdout
> +        stderr = self.stderr.rstrip() if self.stderr else self.stderr
> +        return self.run_error.format(stdout=stdout,
> +                                     stderr=stderr,
>                                       err_reason=self.err_reason)
>  
>      def __call__(self, args=[], quiet=False):
> diff --git a/tests/test_PristineTar.py b/tests/test_PristineTar.py
> index 1e7f2dc..150dbcf 100644
> --- a/tests/test_PristineTar.py
> +++ b/tests/test_PristineTar.py
> @@ -136,7 +136,6 @@ def test_pristine_tar_checkout_nonexistent():
>      ...
>      CommandExecFailed: Pristine-tar couldn't checkout "upstream_1.1.orig.tar.gz": fatal: Path 'upstream_1.1.orig.tar.gz.delta' does not exist in 'refs/heads/pristine-tar'
>      pristine-tar: git show refs/heads/pristine-tar:upstream_1.1.orig.tar.gz.delta failed
> -    <BLANKLINE>
>      """

I was about to do the same co cherry-picked. This doesn't handle the
case of newlines in the error message but there's probably not much we
can do about it.

Thanks!
 -- Guido

>  
>  def test_teardown():
> -- 
> 2.1.4


More information about the git-buildpackage mailing list