From f50a9a4288012663acb4705538e82dea9a0b655c Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 11 Feb 2022 19:47:59 +0100 Subject: ci(commitlint): allow first non-space character to be a quote --- scripts/lintcommit.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'scripts/lintcommit.lua') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 0a7da4d4ef..6871858a0b 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -94,10 +94,24 @@ local function validate_commit(commit_message) return [[Description ends with a period (".").]] end - -- Check that description has exactly one whitespace after colon, followed by - -- a lowercase letter and then any number of letters. - if not string.match(after_colon, '^ %l%a*') then - return [[There should be one whitespace after the colon and the first letter should lowercase.]] + -- Check that description starts with a whitespace. + if after_colon:sub(1,1) ~= " " then + return [[There should be a whitespace after the colon.]] + end + + -- Check that description doesn't start with multiple whitespaces. + if after_colon:sub(1,2) == " " then + return [[There should only be one whitespace after the colon.]] + end + + -- Check that first character after space isn't uppercase. + if string.match(after_colon:sub(2,2), '%u') then + return [[First character should not be uppercase.]] + end + + -- Check that description isn't just whitespaces + if vim.trim(after_colon) == "" then + return [[Description shouldn't be empty.]] end return nil @@ -168,12 +182,14 @@ function M._test() ['ci(tui)!: message with scope and breaking change'] = true, ['vim-patch:8.2.3374: Pyret files are not recognized (#15642)'] = true, ['vim-patch:8.1.1195,8.2.{3417,3419}'] = true, + ['revert: "ci: use continue-on-error instead of "|| true""'] = true, [':no type before colon 1'] = false, [' :no type before colon 2'] = false, [' :no type before colon 3'] = false, ['ci(empty description):'] = false, - ['ci(whitespace as description): '] = false, + ['ci(only whitespace as description): '] = false, ['docs(multiple whitespaces as description): '] = false, + ['revert(multiple whitespaces and then characters as description): description'] = false, ['ci no colon after type'] = false, ['test: extra space after colon'] = false, ['ci: tab after colon'] = false, -- cgit