diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index e20c1cac7..e8b05862b 100644 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -1,3 +1,4 @@ #!/usr/bin/env sh -npm run commitlint --edit ${1} \ No newline at end of file +npm run commitlint --edit ${1} +node ./commit-v.js "$1" \ No newline at end of file diff --git a/commit-v.js b/commit-v.js new file mode 100644 index 000000000..5cafc293c --- /dev/null +++ b/commit-v.js @@ -0,0 +1,12 @@ +import execSync from 'child_process'; + +const commitMessage = process.argv[2]; + +if (commitMessage) { + // Проверяем, содержит ли сообщение коммита определенные ключевые слова + const isPatch = /^(fix|chore)/.test(commitMessage); // Например, если тип "fix" или "chore" + + if (isPatch) { + execSync('npm version patch', { stdio: 'inherit' }); + } +} diff --git a/commitlint.config.js b/commitlint.config.js index 20840c71e..362b26445 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -23,7 +23,9 @@ export default { 'refactor' - Изменения кода, не исправляющие ошибки и не добавляющие функционал 'perf' - Изменения, улучшающие производительность 'test' - Добавление тестов - 'chore' - Изменения в процессе сборки или вспомогательных инструментах`, + 'chore' - Изменения в процессе сборки или вспомогательных инструментах. + + Например: feat [X-01]: я тут накоммитил`, ]; } return [true];