diff mbox series

[1/3] tools/check-glossaries: return 1 in case of failure

Message ID 20260702-pre-commit-v1-1-0ebd211b5d5e@bootlin.com
State New
Headers show
Series Add pre-commit support | expand

Commit Message

Antonin Godard July 2, 2026, 1:59 p.m. UTC
Exit with 1 in case there's an issue with the glossaries. This will be
used in the next commit.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/tools/check-glossaries | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/documentation/tools/check-glossaries b/documentation/tools/check-glossaries
index b5dfe834e..9f1a47126 100755
--- a/documentation/tools/check-glossaries
+++ b/documentation/tools/check-glossaries
@@ -4,6 +4,7 @@  import argparse
 import difflib
 import os
 import re
+import sys
 
 from pathlib import Path
 
@@ -33,6 +34,7 @@  def main():
     # :term:`A <ABIEXTENSION>` :term:`B` :term:`C <CACHE>`
     glossary_re = re.compile(r":term:`(?P<letter>[A-Z]{1})( <(?P<varname>[A-Z_]+)>)?`")
     entry_re = re.compile(r"^   :term:`(?P<entry>.+)`\s*$")
+    exit_code = 0
 
     for rst in glossaries:
 
@@ -74,6 +76,7 @@  def main():
         if diffs:
             print(f"WARNING: {rst}: entries are not properly sorted:")
             print('\n'.join(diffs))
+            exit_code = 1
 
         for letter in glossary:
             try:
@@ -81,9 +84,13 @@  def main():
             except ValueError:
                 print(f"WARNING: {rst}: variable "
                       f"{glossary[letter]} in glossary does not exist")
+                exit_code = 1
             if index > 0 and entries[index - 1].startswith(letter[0]):
                 print(f"WARNING: {rst}: The variable {glossary[letter]} shouldn't be in "
                      "the glossary.")
+                exit_code = 1
+
+    sys.exit(exit_code)
 
 
 if __name__ == "__main__":