From 8e4b640cf473ee4e551bca6d7a36588a882a1829 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Mon, 17 Jul 2023 11:03:18 +0200 Subject: [PATCH] commitlint(plugins): fix issue#124 Add exception to bodySoftMaxLineLength when line exceeds max length but ends with a git commit hash. Fixes https://github.com/nblockchain/conventions/issues/124. --- commitlint/plugins.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/commitlint/plugins.ts b/commitlint/plugins.ts index f772d83e..16f95059 100644 --- a/commitlint/plugins.ts +++ b/commitlint/plugins.ts @@ -399,7 +399,21 @@ export abstract class Plugins { let lineIsFooterNote = Helpers.isFooterNote(line); - if (!isUrl && !lineIsFooterNote) { + let commitHashPattern = `([0-9a-f]{40})`; + let anySinglePunctuationCharOrNothing = `[\.\,\:\;\?\!]?`; + let index = line.search( + commitHashPattern + + anySinglePunctuationCharOrNothing + + `$` + ); + let endsWithCommitHashButRestIsNotTooLong = + index != -1 && index < bodyMaxLineLength; + + if ( + !isUrl && + !lineIsFooterNote && + !endsWithCommitHashButRestIsNotTooLong + ) { offence = true; break; }