mirror of
https://xff.cz/git/u-boot/
synced 2025-09-13 06:32:09 +02:00
patman: add warning for invalid tag
Add a error in patman tool when the commit message contents an invalid tag "Serie-.*" instead of "Series-.*". Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
b29a0dbdc3
commit
a6123333ab
@@ -506,6 +506,17 @@ Tested-by: %s
|
|||||||
'Reviewed-by': {self.joe, self.mary},
|
'Reviewed-by': {self.joe, self.mary},
|
||||||
'Tested-by': {self.leb}})
|
'Tested-by': {self.leb}})
|
||||||
|
|
||||||
|
def testInvalidTag(self):
|
||||||
|
"""Test invalid tag in a patchstream"""
|
||||||
|
text = '''This is a patch
|
||||||
|
|
||||||
|
Serie-version: 2
|
||||||
|
'''
|
||||||
|
with self.assertRaises(ValueError) as exc:
|
||||||
|
pstrm = PatchStream.process_text(text)
|
||||||
|
self.assertEqual("Line 3: Invalid tag = 'Serie-version: 2'",
|
||||||
|
str(exc.exception))
|
||||||
|
|
||||||
def testMissingEnd(self):
|
def testMissingEnd(self):
|
||||||
"""Test a missing END tag"""
|
"""Test a missing END tag"""
|
||||||
text = '''This is a patch
|
text = '''This is a patch
|
||||||
|
@@ -59,6 +59,9 @@ RE_DIFF = re.compile(r'^>.*diff --git a/(.*) b/(.*)$')
|
|||||||
# Detect a context line, like '> @@ -153,8 +153,13 @@ CheckPatch
|
# Detect a context line, like '> @@ -153,8 +153,13 @@ CheckPatch
|
||||||
RE_LINE = re.compile(r'>.*@@ \-(\d+),\d+ \+(\d+),\d+ @@ *(.*)')
|
RE_LINE = re.compile(r'>.*@@ \-(\d+),\d+ \+(\d+),\d+ @@ *(.*)')
|
||||||
|
|
||||||
|
# Detect line with invalid TAG
|
||||||
|
RE_INV_TAG = re.compile('^Serie-([a-z-]*): *(.*)')
|
||||||
|
|
||||||
# States we can be in - can we use range() and still have comments?
|
# States we can be in - can we use range() and still have comments?
|
||||||
STATE_MSG_HEADER = 0 # Still in the message header
|
STATE_MSG_HEADER = 0 # Still in the message header
|
||||||
STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit)
|
STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit)
|
||||||
@@ -318,6 +321,7 @@ class PatchStream:
|
|||||||
leading_whitespace_match = RE_LEADING_WHITESPACE.match(line)
|
leading_whitespace_match = RE_LEADING_WHITESPACE.match(line)
|
||||||
diff_match = RE_DIFF.match(line)
|
diff_match = RE_DIFF.match(line)
|
||||||
line_match = RE_LINE.match(line)
|
line_match = RE_LINE.match(line)
|
||||||
|
invalid_match = RE_INV_TAG.match(line)
|
||||||
tag_match = None
|
tag_match = None
|
||||||
if self.state == STATE_PATCH_HEADER:
|
if self.state == STATE_PATCH_HEADER:
|
||||||
tag_match = RE_TAG.match(line)
|
tag_match = RE_TAG.match(line)
|
||||||
@@ -471,6 +475,11 @@ class PatchStream:
|
|||||||
self._add_warn('Line %d: Ignoring Commit-%s' %
|
self._add_warn('Line %d: Ignoring Commit-%s' %
|
||||||
(self.linenum, name))
|
(self.linenum, name))
|
||||||
|
|
||||||
|
# Detect invalid tags
|
||||||
|
elif invalid_match:
|
||||||
|
raise ValueError("Line %d: Invalid tag = '%s'" %
|
||||||
|
(self.linenum, line))
|
||||||
|
|
||||||
# Detect the start of a new commit
|
# Detect the start of a new commit
|
||||||
elif commit_match:
|
elif commit_match:
|
||||||
self._close_commit()
|
self._close_commit()
|
||||||
|
Reference in New Issue
Block a user