]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
bgit: report unknow branch with a friendly message instead of a stacktrace
authorAlain Spineux <alain@baculasystems.com>
Fri, 22 Jan 2021 10:26:34 +0000 (11:26 +0100)
committerEric Bollengier <eric@baculasystems.com>
Fri, 30 Jun 2023 15:54:36 +0000 (17:54 +0200)
bacula/release/bgit.py

index fd965aa7e744b76157d98814e8a8946cc8997ff6..ac3ae4f93a2e9d25cd154ae1bb476c71b14b5882 100755 (executable)
@@ -39,6 +39,16 @@ def add_file_logger(filename):
 
 def run_cmp_branch(args):
     repo=args.repo
+    # check if the branch exists
+    f1=f2=False
+    for ref in repo.references:
+        f1|=(args.branch1==ref.name)
+        f2|=(args.branch2==ref.name)
+    for found, name in ((f1, args.branch1), (f2, args.branch2)):
+        if not found:
+            print("Branch not found: ", name)
+            return False
+
     if args.switch:
         args.branch1, args.branch2=args.branch2, args.branch1
     if args.short_legend:
@@ -53,6 +63,7 @@ def run_cmp_branch(args):
     commons=repo.merge_base(args.branch1, args.branch2)
     if len(commons)!=1:
         print("cannot find the unique common commit between", args.branch1, args.branch2)
+        return False
 
     common=commons[0]
     # make a list of all know commit in branch-2