mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Update the dangerfile to check for issue links
This commit is contained in:
parent
6f104fecad
commit
36a560dcd0
1 changed files with 29 additions and 1 deletions
|
@ -9,8 +9,10 @@ prHygiene({
|
||||||
});
|
});
|
||||||
|
|
||||||
const RELEASE_NOTES_PATTERN = new RegExp("Release Notes:\\r?\\n\\s+-", "gm");
|
const RELEASE_NOTES_PATTERN = new RegExp("Release Notes:\\r?\\n\\s+-", "gm");
|
||||||
|
const body = danger.github.pr.body;
|
||||||
|
|
||||||
|
const hasReleaseNotes = RELEASE_NOTES_PATTERN.test(body);
|
||||||
|
|
||||||
const hasReleaseNotes = RELEASE_NOTES_PATTERN.test(danger.github.pr.body);
|
|
||||||
if (!hasReleaseNotes) {
|
if (!hasReleaseNotes) {
|
||||||
warn(
|
warn(
|
||||||
[
|
[
|
||||||
|
@ -33,3 +35,29 @@ if (!hasReleaseNotes) {
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ISSUE_LINK_PATTERN = new RegExp(
|
||||||
|
"(?:^|\\s)(?:#(\\d+)|https:\\/\\/github\\.com\\/zed-industries\\/zed\\/issues\\/(\\d+))",
|
||||||
|
"g",
|
||||||
|
);
|
||||||
|
|
||||||
|
const includesIssueUrl = ISSUE_LINK_PATTERN.test(body);
|
||||||
|
|
||||||
|
if (includesIssueUrl) {
|
||||||
|
const matches = body.match(ISSUE_LINK_PATTERN);
|
||||||
|
const issues = matches
|
||||||
|
.map((match) =>
|
||||||
|
match
|
||||||
|
.replace(/^#/, "")
|
||||||
|
.replace(/https:\/\/github\.com\/zed-industries\/zed\/issues\//, ""),
|
||||||
|
)
|
||||||
|
.filter((issue, index, self) => self.indexOf(issue) === index);
|
||||||
|
|
||||||
|
warn(
|
||||||
|
[
|
||||||
|
"This PR includes links to the following GitHub Issues: " +
|
||||||
|
issues.join(", "),
|
||||||
|
"If this pull requests aims to close an issue, please include a `Closes #ISSUE` line at the top of the PR body.",
|
||||||
|
].join("\n"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue