From c9d557a9f2bfceccc507469473e5c0430fab2f02 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 27 Mar 2025 13:20:08 -0400 Subject: [PATCH] add test for version related tags missing a colon --- tools/coding_standard/versiontags.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/coding_standard/versiontags.py b/tools/coding_standard/versiontags.py index ec512a3fad..3f71ba905e 100644 --- a/tools/coding_standard/versiontags.py +++ b/tools/coding_standard/versiontags.py @@ -49,22 +49,42 @@ def check_pending_tag(f): return errors, last_line +def check_bad_tag(f): + pattern = re.compile(r'^ *\.\. +(version(changed|added)|deprecated):\s+\w*') + last_line = "\n" + lineno = 1 + errors = set() + + for line in f: + if pattern.match(line): + errors.add(lineno) + last_line = line + lineno += 1 + + return errors, last_line + def check_file(path): encoding = 'UTF-8' pending_tags = set() + bad_tags = set() try: with open(path, 'r') as f: pending_tags, last_line = check_pending_tag(f) + f.seek(0) + bad_tags, last_line = check_bad_tag(f) except UnicodeDecodeError: encoding = 'ISO-8859-1' try: with open(path, 'r', encoding=encoding) as f: pending_tags, last_line = check_pending_tag(f) + f.seek(0) + bad_tags, last_line = check_bad_tag(f) except Exception: encoding = 'unknown' return { 'pending_tags': pending_tags, + 'bad_tags': bad_tags, 'encoding': encoding } @@ -90,6 +110,9 @@ def check_folder(directory, config, verbose=False): for lineno in result['pending_tags']: print("[Error] Pending version tag @ {}:{}".format(path, lineno)) success = False + for lineno in result['bad_tags']: + print("[Error] Bad version tag @ {}:{}".format(path, lineno)) + success = False if result['encoding'] == 'unknown': print("[Error] Unknown text encoding @ {}".format(path))