zed/script/danger/dangerfile.ts
Marshall Bowers 6c28b7e8b8
danger: Check PR titles (#13053)
This PR sets up Danger to check PR titles for consistency, using
[`danger-plugin-pr-hygiene`](https://github.com/maxdeviant/danger-plugin-pr-hygiene).

<img width="919" alt="Screenshot 2024-06-14 at 11 16 31 AM"
src="https://github.com/zed-industries/zed/assets/1486634/167fe698-2505-422b-8e41-e121d9fe933f">

Release Notes:

- N/A
2024-06-14 11:18:41 -04:00

36 lines
963 B
TypeScript

import { danger, warn } from "danger";
const { prHygiene } = require("danger-plugin-pr-hygiene");
prHygiene({
rules: {
// Don't enable this rule just yet, as it can have false positives.
useImperativeMood: "off",
},
});
const RELEASE_NOTES_PATTERN = new RegExp("Release Notes:\\r?\\n\\s+-", "gm");
const hasReleaseNotes = RELEASE_NOTES_PATTERN.test(danger.github.pr.body);
if (!hasReleaseNotes) {
warn(
[
"This PR is missing release notes.",
"",
'Please add a "Release Notes" section that describes the change:',
"",
"```",
"Release Notes:",
"",
"- (Added|Fixed|Improved) ... ([#<public_issue_number_if_exists>](https://github.com/zed-industries/zed/issues/<public_issue_number_if_exists>)).",
"```",
"",
'If your change is not user-facing, you can use "N/A" for the entry:',
"```",
"Release Notes:",
"",
"- N/A",
"```",
].join("\n"),
);
}