2024-01-01 19:58:21 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-08-20 19:14:37 +00:00
|
|
|
|
|
|
|
// deno-lint-ignore-file no-console
|
|
|
|
|
2023-03-13 18:59:13 +00:00
|
|
|
const prTitle = Deno.args[0];
|
|
|
|
|
|
|
|
if (prTitle == null) {
|
|
|
|
Deno.exit(0); // not a PR
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("PR title:", prTitle);
|
|
|
|
|
2024-06-11 16:47:44 +00:00
|
|
|
if (
|
2024-06-11 23:50:02 +00:00
|
|
|
prTitle.startsWith("chore:") && prTitle.includes("deno_core") &&
|
|
|
|
(prTitle.includes("upgrade") || prTitle.includes("update"))
|
2024-06-11 16:47:44 +00:00
|
|
|
) {
|
|
|
|
console.error([
|
|
|
|
"Please categorize this deno_core upgrade as a 'feat:', 'fix:' or a ",
|
|
|
|
"'refactor:'. If your upgrade does not fall into either of these ",
|
|
|
|
"categories, wait until the next deno_core release.\n\n",
|
|
|
|
"For feats and fixes, please title your PR outlining the fixed issue ",
|
|
|
|
"rather than just `fix: upgrade deno_core` so that users understand the ",
|
|
|
|
"change that was made in the changelog.",
|
|
|
|
].join(""));
|
|
|
|
Deno.exit(1);
|
|
|
|
}
|
|
|
|
|
2023-03-13 18:59:13 +00:00
|
|
|
// This is a release PR, so it's valid.
|
|
|
|
if (/^[^\s]+\.[^\s]+\.[^\s]+$/.test(prTitle)) {
|
|
|
|
console.log("Valid.");
|
|
|
|
Deno.exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
const validPrefixes = [
|
|
|
|
"chore",
|
|
|
|
"fix",
|
|
|
|
"feat",
|
|
|
|
"perf",
|
|
|
|
"ci",
|
|
|
|
"cleanup",
|
|
|
|
"docs",
|
|
|
|
"bench",
|
|
|
|
"build",
|
|
|
|
"refactor",
|
|
|
|
"test",
|
|
|
|
// allow Revert PRs because it allows us to remove the landed
|
|
|
|
// commit from the generated changelog
|
|
|
|
"Revert ",
|
2023-03-18 21:15:45 +00:00
|
|
|
// allow Reland PRs because when editing the changelog, it helps us identify
|
|
|
|
// commits that were reverted, but then relanded
|
|
|
|
"Reland ",
|
2023-03-16 22:42:29 +00:00
|
|
|
// Allow landing breaking changes that are properly marked
|
|
|
|
"BREAKING",
|
2023-03-13 18:59:13 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if (validPrefixes.some((prefix) => prTitle.startsWith(prefix))) {
|
|
|
|
console.log("Valid.");
|
|
|
|
} else {
|
|
|
|
console.error(
|
|
|
|
"The PR title must start with one of the following prefixes:\n",
|
|
|
|
);
|
|
|
|
for (const prefix of validPrefixes) {
|
|
|
|
console.error(` - ${prefix}`);
|
|
|
|
}
|
|
|
|
console.error(
|
|
|
|
"\nPlease fix the PR title according to https://www.conventionalcommits.org " +
|
|
|
|
"then push an empty commit to reset the CI.",
|
|
|
|
);
|
|
|
|
Deno.exit(1);
|
|
|
|
}
|