bin/gen_release_notes.py: escape special rST characters
Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6869>
This commit is contained in:
parent
ae7975ecd4
commit
636f770233
|
@ -25,6 +25,7 @@ import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
@ -74,7 +75,7 @@ TEMPLATE = Template(textwrap.dedent("""\
|
||||||
------------
|
------------
|
||||||
|
|
||||||
%for f in features:
|
%for f in features:
|
||||||
- ${f}
|
- ${rst_escape(f)}
|
||||||
%endfor
|
%endfor
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ TEMPLATE = Template(textwrap.dedent("""\
|
||||||
---------
|
---------
|
||||||
|
|
||||||
%for b in bugs:
|
%for b in bugs:
|
||||||
- ${b}
|
- ${rst_escape(b)}
|
||||||
%endfor
|
%endfor
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,15 +92,27 @@ TEMPLATE = Template(textwrap.dedent("""\
|
||||||
%for c, author_line in changes:
|
%for c, author_line in changes:
|
||||||
%if author_line:
|
%if author_line:
|
||||||
|
|
||||||
${c}
|
${rst_escape(c)}
|
||||||
|
|
||||||
%else:
|
%else:
|
||||||
- ${c}
|
- ${rst_escape(c)}
|
||||||
%endif
|
%endif
|
||||||
%endfor
|
%endfor
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
|
|
||||||
|
def rst_escape(unsafe_str: str) -> str:
|
||||||
|
"Escape rST special chars when they follow or preceed a whitespace"
|
||||||
|
special = re.escape(r'`<>*_#[]|')
|
||||||
|
unsafe_str = re.sub(r'(^|\s)([' + special + r'])',
|
||||||
|
r'\1\\\2',
|
||||||
|
unsafe_str)
|
||||||
|
unsafe_str = re.sub(r'([' + special + r'])(\s|$)',
|
||||||
|
r'\\\1\2',
|
||||||
|
unsafe_str)
|
||||||
|
return unsafe_str
|
||||||
|
|
||||||
|
|
||||||
async def gather_commits(version: str) -> str:
|
async def gather_commits(version: str) -> str:
|
||||||
p = await asyncio.create_subprocess_exec(
|
p = await asyncio.create_subprocess_exec(
|
||||||
'git', 'log', '--oneline', f'mesa-{version}..', '--grep', r'Closes: \(https\|#\).*',
|
'git', 'log', '--oneline', f'mesa-{version}..', '--grep', r'Closes: \(https\|#\).*',
|
||||||
|
@ -249,6 +262,7 @@ async def main() -> None:
|
||||||
header_underline=header_underline,
|
header_underline=header_underline,
|
||||||
previous_version=previous_version,
|
previous_version=previous_version,
|
||||||
vk_version=CURRENT_VK_VERSION,
|
vk_version=CURRENT_VK_VERSION,
|
||||||
|
rst_escape=rst_escape,
|
||||||
))
|
))
|
||||||
except:
|
except:
|
||||||
print(exceptions.text_error_template().render())
|
print(exceptions.text_error_template().render())
|
||||||
|
|
Loading…
Reference in New Issue