aboutsummaryrefslogtreecommitdiff
path: root/scripts/lintcommit.lua
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2022-10-24 13:24:08 +0200
committerGitHub <noreply@github.com>2022-10-24 04:24:08 -0700
commit1248c12666dc4d8fb801c2a8dbc355027f8f9bbe (patch)
treeff57b1f3d15219b4147a4cd4e981575b834d0abb /scripts/lintcommit.lua
parentf445f6b0039ebe54680f2d140fc90c4a50a2647b (diff)
downloadrneovim-1248c12666dc4d8fb801c2a8dbc355027f8f9bbe.tar.gz
rneovim-1248c12666dc4d8fb801c2a8dbc355027f8f9bbe.tar.bz2
rneovim-1248c12666dc4d8fb801c2a8dbc355027f8f9bbe.zip
ci(lintcommit): enforce common scope names #20393
This is useful to ensure related commits aren't spread out when generating the changelog.
Diffstat (limited to 'scripts/lintcommit.lua')
-rw-r--r--scripts/lintcommit.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua
index 16326cfe66..87a8e62503 100644
--- a/scripts/lintcommit.lua
+++ b/scripts/lintcommit.lua
@@ -86,11 +86,28 @@ local function validate_commit(commit_message)
vim.inspect(allowed_types))
end
- -- Check if scope is empty
+ -- Check if scope is appropriate
if before_colon:match("%(") then
local scope = vim.trim(before_colon:match("%((.*)%)"))
+
if scope == '' then
- return [[Scope can't be empty.]]
+ return [[Scope can't be empty]]
+ end
+
+ if vim.startswith(scope, "nvim_") then
+ return [[Scope should be "api" instead of "nvim_..."]]
+ end
+
+ local alternative_scope = {
+ ['filetype.vim'] = 'filetype',
+ ['filetype.lua'] = 'filetype',
+ ['tree-sitter'] = 'treesitter',
+ ['ts'] = 'treesitter',
+ ['hl'] = 'highlight',
+ }
+
+ if alternative_scope[scope] then
+ return ('Scope should be "%s" instead of "%s"'):format(alternative_scope[scope], scope)
end
end