jenkins-bot submitted this change.
Fix noreferences.py skipping references header without trailing newline
Bug: T424283
Change-Id: I3fc4139a90d85fe19d362ae39f52f14a14e4717b
---
M scripts/noreferences.py
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 996d9cc..de341a4 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -668,7 +668,7 @@
# Set the edit summary key for this case
self.summary_key = 'noreferences-add-tag'
for section in i18n.translate(self.site, referencesSections) or []:
- sectionR = re.compile(fr'\r?\n=+ *{section} *=+ *\r?\n')
+ sectionR = re.compile(fr'\r?\n=+ *{section} *=+ *(?=\r?\n|$)')
index = 0
while index < len(oldText):
match = sectionR.search(oldText, index)
@@ -684,10 +684,11 @@
r'^((?:\s*(?:\{\{[^\{\}]*?\}\}|<!--.*?-->))*)',
flags=re.DOTALL)
return (
- oldText[:match.end() - 1]
+ oldText[:match.end()]
+ templates_or_comments.sub(
fr'\1\n{self.referencesText}\n',
- oldText[match.end() - 1:])
+ oldText[match.end():]
+ )
)
else:
break
To view, visit change 1277231. To unsubscribe, or for help writing mail filters, visit settings.