All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] patman: add warning for invalid tag
@ 2021-07-22 14:51 Patrick Delaunay
  2021-07-23  3:07 ` Simon Glass
  2021-07-24 21:11 ` Simon Glass
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Delaunay @ 2021-07-22 14:51 UTC (permalink / raw)
  To: u-boot; +Cc: Patrick Delaunay, Simon Glass, U-Boot STM32

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>

---
I create this patch to avoid my frequent mistake:
using "Serie-" tag instead of "Series-" as it is done in [1].

RE_INV_TAG can be extended to other frequent errors.

Any "Serie-" tag is refused with the patch, for example:

ValueError: Line 28: Invalid tag =
   'Serie-cc: Marek Behún <marek.behun@nic.cz>'

[1] http://patchwork.ozlabs.org/project/uboot/patch/20210720203353.1.I550b95f6d12d59aeef5b744d837dbb360037d39e@changeid/


Changes in v2:
- add patman test testInvalidTag

 tools/patman/func_test.py   | 11 +++++++++++
 tools/patman/patchstream.py |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 1ce6448d00..9871bb580d 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -506,6 +506,17 @@ Tested-by: %s
             'Reviewed-by': {self.joe, self.mary},
             '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):
         """Test a missing END tag"""
         text = '''This is a patch
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index a44cd861af..b960292427 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -59,6 +59,9 @@ RE_DIFF = re.compile(r'^>.*diff --git a/(.*) b/(.*)$')
 # Detect a context line, like '> @@ -153,8 +153,13 @@ CheckPatch
 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?
 STATE_MSG_HEADER = 0        # Still in the message header
 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)
         diff_match = RE_DIFF.match(line)
         line_match = RE_LINE.match(line)
+        invalid_match = RE_INV_TAG.match(line)
         tag_match = None
         if self.state == STATE_PATCH_HEADER:
             tag_match = RE_TAG.match(line)
@@ -471,6 +475,11 @@ class PatchStream:
                 self._add_warn('Line %d: Ignoring Commit-%s' %
                                (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
         elif commit_match:
             self._close_commit()
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] patman: add warning for invalid tag
  2021-07-22 14:51 [PATCH v2] patman: add warning for invalid tag Patrick Delaunay
@ 2021-07-23  3:07 ` Simon Glass
  2021-07-24 21:11 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-07-23  3:07 UTC (permalink / raw)
  To: Patrick Delaunay; +Cc: U-Boot Mailing List, U-Boot STM32

On Thu, 22 Jul 2021 at 08:51, Patrick Delaunay
<patrick.delaunay@foss.st.com> wrote:
>
> 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>
>
> ---
> I create this patch to avoid my frequent mistake:
> using "Serie-" tag instead of "Series-" as it is done in [1].
>
> RE_INV_TAG can be extended to other frequent errors.
>
> Any "Serie-" tag is refused with the patch, for example:
>
> ValueError: Line 28: Invalid tag =
>    'Serie-cc: Marek Behún <marek.behun@nic.cz>'
>
> [1] http://patchwork.ozlabs.org/project/uboot/patch/20210720203353.1.I550b95f6d12d59aeef5b744d837dbb360037d39e@changeid/
>
>
> Changes in v2:
> - add patman test testInvalidTag
>
>  tools/patman/func_test.py   | 11 +++++++++++
>  tools/patman/patchstream.py |  9 +++++++++
>  2 files changed, 20 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] patman: add warning for invalid tag
  2021-07-22 14:51 [PATCH v2] patman: add warning for invalid tag Patrick Delaunay
  2021-07-23  3:07 ` Simon Glass
@ 2021-07-24 21:11 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-07-24 21:11 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List, Patrick Delaunay, U-Boot STM32

On Thu, 22 Jul 2021 at 08:51, Patrick Delaunay
<patrick.delaunay@foss.st.com> wrote:
>
> 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>
>
> ---
> I create this patch to avoid my frequent mistake:
> using "Serie-" tag instead of "Series-" as it is done in [1].
>
> RE_INV_TAG can be extended to other frequent errors.
>
> Any "Serie-" tag is refused with the patch, for example:
>
> ValueError: Line 28: Invalid tag =
>    'Serie-cc: Marek Behún <marek.behun@nic.cz>'
>
> [1] http://patchwork.ozlabs.org/project/uboot/patch/20210720203353.1.I550b95f6d12d59aeef5b744d837dbb360037d39e@changeid/
>
>
> Changes in v2:
> - add patman test testInvalidTag
>
>  tools/patman/func_test.py   | 11 +++++++++++
>  tools/patman/patchstream.py |  9 +++++++++
>  2 files changed, 20 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-24 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 14:51 [PATCH v2] patman: add warning for invalid tag Patrick Delaunay
2021-07-23  3:07 ` Simon Glass
2021-07-24 21:11 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.