releasenotes: use re.MULTILINE mode when checking admonitions
authorCraig Ozancin <c.ozancin@gmail.com>
Fri, 30 Sep 2022 09:05:48 -0600
changeset 49519 943509a58d29
parent 49517 52464a20add0
child 49520 eb02decdf0ab
releasenotes: use re.MULTILINE mode when checking admonitions Release note admonitions must start at the beginning of a line within the changeset description: .. admonitions:: The checkadmonitions function search for and validates admonitions. Unfortunately, since the ctx.description is multi-line, the regex search always fails unless the admonition is on the first line. This changeset adds re.MULTILINE to the re.compile to make the re opbject multi-line.
hgext/releasenotes.py
tests/test-releasenotes-formatting.t
--- a/hgext/releasenotes.py	Wed Oct 05 15:45:05 2022 -0400
+++ b/hgext/releasenotes.py	Fri Sep 30 09:05:48 2022 -0600
@@ -70,7 +70,7 @@
     (b'api', _(b'API Changes')),
 ]
 
-RE_DIRECTIVE = re.compile(br'^\.\. ([a-zA-Z0-9_]+)::\s*([^$]+)?$')
+RE_DIRECTIVE = re.compile(br'^\.\. ([a-zA-Z0-9_]+)::\s*([^$]+)?$', re.MULTILINE)
 RE_ISSUE = br'\bissue ?[0-9]{4,6}(?![0-9])\b'
 
 BULLET_SECTION = _(b'Other Changes')
--- a/tests/test-releasenotes-formatting.t	Wed Oct 05 15:45:05 2022 -0400
+++ b/tests/test-releasenotes-formatting.t	Fri Sep 30 09:05:48 2022 -0600
@@ -387,6 +387,8 @@
 
   $ touch a
   $ hg -q commit -A -l - << EOF
+  > commit 2
+  > 
   > .. asf::
   > 
   >    First paragraph under this admonition.
@@ -395,7 +397,7 @@
 Suggest similar admonition in place of the invalid one.
 
   $ hg releasenotes -r . -c
-  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+  Invalid admonition 'asf' present in changeset 99fa3c800c5e
 
   $ touch b
   $ hg -q commit -A -l - << EOF
@@ -405,7 +407,7 @@
   > EOF
 
   $ hg releasenotes -r . -c
-  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  Invalid admonition 'fixes' present in changeset 4737b1b5afd1
   (did you mean fix?)
 
   $ cd ..