diff mbox series

buildhistory-diff: fix handling of a missing previous build revision

Message ID 20261007075935.12-1-maxin.john@gehealthcare.com
State New
Headers show
Series buildhistory-diff: fix handling of a missing previous build revision | expand

Commit Message

Maxin John Oct. 7, 2026, 7:59 a.m. UTC
When buildhistory has no previous build revision, GitPython raises BadName,
causing buildhistory-diff to print a traceback as shown below:

Traceback (most recent call last):
    ...
    ...	raise BadName(name)
gitdb.exc.BadName: Ref 'build-minus-1' did not resolve to an object

Catch both revision lookup exceptions and compare the parsed revisions with
the parser default to show the intended message.

Signed-off-by: Maxin John <maxin.john@gehealthcare.com>
---
 scripts/buildhistory-diff | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index a6e785aa23..aefe8b9fae 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -115,8 +115,8 @@  def main():
         changes = process_changes(args.buildhistory_dir, fromrev, torev,
                                   args.report_all, args.report_ver, args.sigs,
                                   args.sigsdiff, args.exclude_path)
-    except gitdb.exc.BadObject as e:
-        if not args.revisions:
+    except (gitdb.exc.BadObject, gitdb.exc.BadName) as e:
+        if args.revisions == parser.get_default('revisions'):
             sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
             parser.print_help()
         else: