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 <[email protected]>
---
 scripts/buildhistory-diff | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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:
-- 
2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#247377): 
https://lists.openembedded.org/g/openembedded-core/message/247377
Mute This Topic: https://lists.openembedded.org/mt/121624233/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to