From 3534923bd2fe933089f8672fbef88cda2bc4d9d8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 25 Jun 2024 07:32:43 +0200 Subject: [PATCH] build: account for `subjectAndDescription` null in patch linting (#42636) fix: account for subjectAndDescription null in patch linting --- script/lint.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/lint.js b/script/lint.js index fd5d57e2f4a7..775895770f98 100755 --- a/script/lint.js +++ b/script/lint.js @@ -252,8 +252,10 @@ const LINTERS = [{ const allOk = filenames.length > 0 && filenames.map(f => { const patchText = fs.readFileSync(f, 'utf8'); - const subjectAndDescription = /Subject: (.*?)\n\n([\s\S]*?)\s*(?=diff)/ms.exec(patchText); - if (!subjectAndDescription[2]) { + + const regex = /Subject: (.*?)\n\n([\s\S]*?)\s*(?=diff)/ms; + const subjectAndDescription = regex.exec(patchText); + if (!subjectAndDescription?.[2]) { console.warn(`Patch file '${f}' has no description. Every patch must contain a justification for why the patch exists and the plan for its removal.`); return false; }