fix(dev-infra): properly handle multiline regex of commit body (#36632)
Previously, the commit message body regex only matched the first line of the body. This change corrects the regex to match the entire line. PR Close #36632
This commit is contained in:
parent
f0ec4ae941
commit
5e579c4dc9
|
@ -20,7 +20,7 @@ const SQUASH_PREFIX_RE = /^squash! /i;
|
|||
const REVERT_PREFIX_RE = /^revert:? /i;
|
||||
const TYPE_SCOPE_RE = /^(\w+)(?:\(([^)]+)\))?\:\s(.+)$/;
|
||||
const COMMIT_HEADER_RE = /^(.*)/i;
|
||||
const COMMIT_BODY_RE = /^.*\n\n(.*)/i;
|
||||
const COMMIT_BODY_RE = /^.*\n\n([\s\S]*)$/;
|
||||
|
||||
/** Parse a full commit message into its composite parts. */
|
||||
export function parseCommitMessage(commitMsg: string) {
|
||||
|
@ -79,6 +79,9 @@ export function validateCommitMessage(
|
|||
const config = getAngularDevConfig<'commitMessage', CommitMessageConfig>().commitMessage;
|
||||
const commit = parseCommitMessage(commitMsg);
|
||||
|
||||
////////////////////////////////////
|
||||
// Checking revert, squash, fixup //
|
||||
////////////////////////////////////
|
||||
if (commit.isRevert) {
|
||||
return true;
|
||||
}
|
||||
|
@ -102,6 +105,9 @@ export function validateCommitMessage(
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// Checking commit header //
|
||||
////////////////////////////
|
||||
if (commit.header.length > config.maxLineLength) {
|
||||
error(`The commit message header is longer than ${config.maxLineLength} characters`);
|
||||
return false;
|
||||
|
@ -122,6 +128,16 @@ export function validateCommitMessage(
|
|||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// Checking commit body //
|
||||
//////////////////////////
|
||||
|
||||
// Commit bodies are not checked for fixups and squashes as they will be squashed into
|
||||
// another commit in the history anyway.
|
||||
if (commit.isFixup || commit.isSquash) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (commit.bodyWithoutLinking.trim().length < config.minBodyLength) {
|
||||
error(`The commit message body does not meet the minimum length of ${
|
||||
config.minBodyLength} characters`);
|
||||
|
|
Loading…
Reference in New Issue