diff mbox series

[auh,1/2] Handle 'nothing to commit' gracefully

Message ID 20260105224745.581549-2-t.f.g.geelen@gmail.com
State New
Headers show
Series [auh,1/2] Handle 'nothing to commit' gracefully | expand

Commit Message

Tom Geelen Jan. 5, 2026, 10:47 p.m. UTC
In case devtool hits a problem where there is no file to commit it would normally reports the full git error. This is an
 unintentional side effect as something else went wrong (devtool upgrade most likely).

Catch the particular 'nothing to commit' message and ensure an early return without raising a cascade of secondary problems.

Tested with perlcross compile failure where no file changes were made. Now the error is handled gracefully.
Other errors like 'merge conflict' are still raised as before.
diff mbox series

Patch

diff --git a/upgrade-helper.py b/upgrade-helper.py
index 165fd42..002c3dc 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -414,14 +414,12 @@  class Updater(object):
                 I("The commit will be reverted to follow the policy set in the configuration file.")
                 self.git.revert("HEAD")
         except Error as e:
-            msg = ''
-
-            for line in e.stdout.split("\n"):
-                if line.find("nothing to commit") == 0:
-                    msg = "Nothing to commit!"
-                    I(" %s: %s" % (pns, msg))
-
-            I(" %s: %s" % (pns, e.stdout))
+            out = (e.stdout or "")
+            err = (e.stderr or "")
+            combined = out + ("\n" if out and err else "") + err
+            if "nothing to commit" in combined:
+                I(" %s: nothing to commit" % pns)
+                return
             raise e
 
     def send_status_mail(self, statistics_summary, attachments):