Skip to content

Commit

Permalink
checkpatch: Check if some tags are wrongly written.
Browse files Browse the repository at this point in the history
Currently, there are some patches with the tags wrongly written (with
space instead of dash ) and this may prevent some automatic system or CI
to detect them correctly.

This commit adds a check in checkpatch to be sure the tag is written
correctly with dash and not with space.

The tags supported by the commit are:
Acked-by, Reported-at, Reported-by, Requested-by, Reviewed-by, Submitted-at
and Suggested-by.

It's not necessary to add "Signed-off-by" since it's already checked in
checkpatch.

Signed-off-by: Timothy Redaelli <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
drizzt authored and igsilya committed Nov 4, 2021
1 parent 9f22583 commit c5d384f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/checkpatch.at
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,63 @@ try_checkpatch \
"

AT_CLEANUP

AT_SETUP([checkpatch - malformed tags])
try_checkpatch \
" Author: A

Acked by: foo...
Signed-off-by: A" \
"ERROR: Acked-by tag is malformed.
1: Acked by: foo...
"
try_checkpatch \
" Author: A

Reported at: foo...
Signed-off-by: A" \
"ERROR: Reported-at tag is malformed.
1: Reported at: foo...
"
try_checkpatch \
" Author: A

Reported by: foo...
Signed-off-by: A" \
"ERROR: Reported-by tag is malformed.
1: Reported by: foo...
"
try_checkpatch \
" Author: A

Requested by: foo...
Signed-off-by: A" \
"ERROR: Requested-by tag is malformed.
1: Requested by: foo...
"
try_checkpatch \
" Author: A

Reviewed by: foo...
Signed-off-by: A" \
"ERROR: Reviewed-by tag is malformed.
1: Reviewed by: foo...
"
try_checkpatch \
" Author: A

Submitted at: foo...
Signed-off-by: A" \
"ERROR: Submitted-at tag is malformed.
1: Submitted at: foo...
"
try_checkpatch \
" Author: A

Suggested by: foo...
Signed-off-by: A" \
"ERROR: Suggested-by tag is malformed.
1: Suggested by: foo...
"

AT_CLEANUP
15 changes: 15 additions & 0 deletions utilities/checkpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,16 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
is_gerrit_change_id = re.compile(r'(\s*(change-id: )(.*))$',
re.I | re.M | re.S)

tags_typos = {
r'^Acked by:': 'Acked-by:',
r'^Reported at:': 'Reported-at:',
r'^Reported by:': 'Reported-by:',
r'^Requested by:': 'Requested-by:',
r'^Reviewed by:': 'Reviewed-by:',
r'^Submitted at:': 'Submitted-at:',
r'^Suggested by:': 'Suggested-by:',
}

reset_counters()

for line in text.splitlines():
Expand Down Expand Up @@ -842,6 +852,11 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
print("%d: %s\n" % (lineno, line))
elif spellcheck:
check_spelling(line, False)
for typo, correct in tags_typos.items():
m = re.match(typo, line, re.I)
if m:
print_error("%s tag is malformed." % (correct[:-1]))
print("%d: %s\n" % (lineno, line))

elif parse == PARSE_STATE_CHANGE_BODY:
newfile = hunks.match(line)
Expand Down

0 comments on commit c5d384f

Please sign in to comment.