Blob Blame Raw
From 60a8f5e3f0500720077b200ce3be46772db4f093 Mon Sep 17 00:00:00 2001
From: Aleš Matěj <amatej@redhat.com>
Date: Mon, 24 Jun 2019 16:13:28 +0200
Subject: [PATCH] Prevent printing empty Error Summary (RhBug: 1690414)

When test transaction fails we generate Error Summary but it contains
information only if the error happened because of lacking disk space
otherwise we get the headline "Error Summary" without any text this
commit prevents this.
---
 dnf/base.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/dnf/base.py b/dnf/base.py
index 2c5d17e..0f8b77e 100644
--- a/dnf/base.py
+++ b/dnf/base.py
@@ -858,8 +858,12 @@ class Base(object):
                 for descr in tserrors:
                     errstring += '  %s\n' % ucd(descr)
 
-                raise dnf.exceptions.Error(errstring + '\n' +
-                                        self._trans_error_summary(errstring))
+                summary = self._trans_error_summary(errstring)
+                if summary:
+                    errstring += '\n' + summary
+
+                raise dnf.exceptions.Error(errstring)
+
 
             logger.info(_('Transaction test succeeded.'))
             timer()
@@ -911,6 +915,9 @@ class Base(object):
                     'At least %dMB more space needed on the %s filesystem.',
                     disk[k]) % (disk[k], k) + '\n'
 
+        if not summary:
+            return None
+
         summary = _('Error Summary') + '\n-------------\n' + summary
 
         return summary
--
libgit2 0.28.2