A new check for common mistakes while formatting a 'Fixes:' tag.
Signed-off-by: Ilya Maximets <[email protected]>
---
tests/checkpatch.at | 69 +++++++++++++++++++++++++++++++++++++++++
utilities/checkpatch.py | 9 ++++++
2 files changed, 78 insertions(+)
diff --git a/tests/checkpatch.at b/tests/checkpatch.at
index 0a2cca34e..9ab87410e 100755
--- a/tests/checkpatch.at
+++ b/tests/checkpatch.at
@@ -464,3 +464,72 @@ ERROR: Inappropriate non-ascii characters detected.
"
AT_CLEANUP
+
+
+m4_define([FIXES_TAG_ERROR], [dnl
+ERROR: \"Fixes\" tag is malformed.
+Use the following format:
+ git log -1 --pretty=format:\"Fixes: %h (\\\"%s\\\")\" --abbrev=12 COMMIT_REF
+])
+
+AT_SETUP([checkpatch - Fixes tag])
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ Fixes: 123456789abc (\"commit name\")
+ Signed-off-by: A"
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ fixes: 123456789abc (\"commit name\")
+ Signed-off-by: A" \
+ "FIXES_TAG_ERROR
+1: fixes: 123456789abc (\"commit name\")
+"
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ Fixes: 12345678 (\"commit name\")
+ Signed-off-by: A" \
+ "FIXES_TAG_ERROR
+1: Fixes: 12345678 (\"commit name\")
+"
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ Fixes: 1234567890abcdef1234567890abcdef12345678 (\"commit name\")
+ Signed-off-by: A" \
+ "FIXES_TAG_ERROR
+1: Fixes: 1234567890abcdef1234567890abcdef12345678 (\"commit name\")
+"
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ Fixes: 123456789abc \"commit name\"
+ Signed-off-by: A" \
+ "FIXES_TAG_ERROR
+1: Fixes: 123456789abc \"commit name\"
+"
+
+try_checkpatch \
+ "Author: A
+ Commit: A
+
+ Fixes: 123456789abc (\"some very long commit name that doesn\'t fit into
+ a single line, but should not be wrapped.\")
+ Signed-off-by: A" \
+ "FIXES_TAG_ERROR
+1: Fixes: 123456789abc (\"some very long commit name that doesn\'t fit into
+"
+
+AT_CLEANUP
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index de2420e1f..887928404 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -793,6 +793,8 @@ def ovs_checkpatch_parse(text, filename, author=None,
committer=None):
re.I | re.M | re.S)
is_gerrit_change_id = re.compile(r'(\s*(change-id: )(.*))$',
re.I | re.M | re.S)
+ is_fixes = re.compile(r'(\s*(Fixes:)(.*))$', re.I | re.M | re.S)
+ is_fixes_exact = re.compile(r'^Fixes: [0-9a-f]{12} \(".*"\)$')
tags_typos = {
r'^Acked by:': 'Acked-by:',
@@ -895,6 +897,13 @@ def ovs_checkpatch_parse(text, filename, author=None,
committer=None):
print_error(
"Remove Gerrit Change-Id's before submitting upstream.")
print("%d: %s\n" % (lineno, line))
+ elif is_fixes.match(line) and not is_fixes_exact.match(line):
+ print_error('"Fixes" tag is malformed.\n'
+ 'Use the following format:\n'
+ ' git log -1 '
+ '--pretty=format:"Fixes: %h (\\\"%s\\\")" '
+ '--abbrev=12 COMMIT_REF\n')
+ print("%d: %s\n" % (lineno, line))
elif spellcheck:
check_spelling(line, False)
for typo, correct in tags_typos.items():
--
2.34.3
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev