mirror of
https://github.com/denoland/deno
synced 2024-08-27 12:00:17 +00:00
![Bartek Iwańczuk](/assets/img/avatar_default.png)
Allows to use `BREAKING` prefix in the PR title. This change will allow us to land PRs that change behavior with `DENO_FUTURE=1` env var, and prepare for Deno 2.0 release.
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
const prTitle = Deno.args[0];
|
|
|
|
if (prTitle == null) {
|
|
Deno.exit(0); // not a PR
|
|
}
|
|
|
|
console.log("PR title:", prTitle);
|
|
|
|
// 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 ",
|
|
// allow Reland PRs because when editing the changelog, it helps us identify
|
|
// commits that were reverted, but then relanded
|
|
"Reland ",
|
|
// Allow landing breaking changes that are properly marked
|
|
"BREAKING",
|
|
// Allow landing breaking changes that will be applied in Deno 2, or available
|
|
// immediately with DENO_FUTURE=1 env var
|
|
"FUTURE",
|
|
];
|
|
|
|
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);
|
|
}
|