File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,15 @@ task createDetektPreCommitHook() {
17
17
"""
18
18
" chmod +x .git/hooks/pre-commit" . execute()
19
19
}
20
+
21
+ task createConventionalMessagePreCommitHook () {
22
+ def gitHooksDirectory = new File (" $project . rootDir /.git/hooks/" )
23
+ if (! gitHooksDirectory. exists()) gitHooksDirectory. mkdirs()
24
+ new File (" $project . rootDir /.git/hooks" , " commit-msg" ). text = """
25
+ #!/bin/bash
26
+ echo "Running Conventional Commit check"
27
+ commit_message="\$ 1"
28
+ ./scripts/conventional-pre-commit.sh "\$ commit_message"
29
+ """
30
+ " chmod +x .git/hooks/commit-msg" . execute()
31
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ if ! grep -qE " ^\bbuild\b|\bchore\b|\bci\b|\bdocs\b|\bfeat\b|\bfix\b|\bperf\b|\brefactor\b|\brevert\b|\bstyle\b|\btest\b(\([a-z ]+\)!)?: [\w ]+$" " $1 " ; then
4
+ cat $1
5
+ echo "
6
+ Your commit message doesn't conform to Convential Commit Rules (https://www.conventionalcommits.org/).
7
+ At a minimum, your commit should start with one of the below keywords:
8
+ build: chore: ci: docs: feat: fix: perf: refactor: revert: style: test:
9
+ Example commit message to add a feature: 'feat: Changed something to add a lovely new feature'
10
+ Example commit message to fix an issue: 'fix: Removed infinite loop causing that annoying bug'
11
+ "
12
+ exit 1
13
+ fi
You can’t perform that action at this time.
0 commit comments