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 <martin@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63031
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
Martin Roth 2022-03-22 17:59:27 -06:00 committed by Martin L Roth
parent 619086d105
commit 9e33723d9b
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@ OUTPUT: json format output that can be used to post comment in gerrit
import os import os
import sys import sys
import json import json
import re
data = {} data = {}
data['comments'] = [] data['comments'] = []
@ -38,6 +39,11 @@ def parse_file(input_file):
file_path = temp[1].split(":")[0] file_path = temp[1].split(":")[0]
line_number = temp[1].split(":")[1] line_number = temp[1].split(":")[1]
update_struct( file_path.strip(), msg_output, str(line_number) ) 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: else:
continue continue
fp.close() fp.close()