forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): verify the PR title as part of linting (denoland#18163)
This verifies the PR title as part of the lint step.
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2018-2023 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 ", | ||
]; | ||
|
||
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); | ||
} |