From 9e33723d9bfe94318a086d04f34ca4850f54d857 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Tue, 22 Mar 2022 17:59:27 -0600 Subject: [PATCH] util/lint: Add commit message parsing to checkpatch_json script The commit message wasn't being parsed because there's no filename associated with it in the patch output. This change adds the "filename" for the commit message in Gerrit for any errors that have a line number but no filename. calculations is intentionally misspelled as cacluations as a test. Change-Id: Ie7a2ef06419c7090c8e44b3b734b1edf966597cc Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/c/coreboot/+/63031 Tested-by: build bot (Jenkins) Reviewed-by: Elyes Haouas --- util/lint/checkpatch_json.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/lint/checkpatch_json.py b/util/lint/checkpatch_json.py index 81946cabc7..341bc57733 100755 --- a/util/lint/checkpatch_json.py +++ b/util/lint/checkpatch_json.py @@ -10,6 +10,7 @@ OUTPUT: json format output that can be used to post comment in gerrit import os import sys import json +import re data = {} data['comments'] = [] @@ -38,6 +39,11 @@ def parse_file(input_file): file_path = temp[1].split(":")[0] line_number = temp[1].split(":")[1] update_struct( file_path.strip(), msg_output, str(line_number) ) + elif re.search("^\d+:\Z",line) != "None" and line.startswith("#"): + file_path="/COMMIT_MSG" + line = line.replace('#', '') + line_number = int(line.split(":")[0]) + 2 + update_struct( file_path.strip(), msg_output, str(line_number) ) else: continue fp.close()