chore: lint patch descriptions (#20919)

This commit is contained in:
Jeremy Apthorp 2019-11-04 11:04:18 -08:00 committed by GitHub
parent 04da8a10eb
commit 4de04da27a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,7 +137,7 @@ const LINTERS = [ {
key: 'patches',
roots: ['patches'],
test: () => true,
run: () => {
run: (opts, filenames) => {
const patchesDir = path.resolve(__dirname, '../patches')
for (const patchTarget of fs.readdirSync(patchesDir)) {
const targetDir = path.resolve(patchesDir, patchTarget)
@ -180,6 +180,18 @@ const LINTERS = [ {
}
}
}
let ok = true
filenames.filter(f => f.endsWith('.patch')).forEach(f => {
const patchText = fs.readFileSync(f, 'utf8')
if (/^Subject: .*$\s+^diff/.test(patchText)) {
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.`)
ok = false
}
})
if (!ok) {
process.exit(1)
}
}
}]