-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.lefthook.yaml
More file actions
44 lines (41 loc) · 1.38 KB
/
.lefthook.yaml
File metadata and controls
44 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# yaml-language-server: $schema=https://raw.githubusercontent.com/evilmartians/lefthook/refs/heads/master/schema.json
# https://lefthook.dev/configuration/
output: [ summary ]
pre-commit:
skip: [ merge, rebase ]
parallel: true
commands:
branch-name:
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
if ! [[ "$branch_name" =~ ^(feature|fix)/ ]]; then
echo "Error: Branch name must start with 'feature/' or 'fix/'. Your branch: $branch_name"
exit 1
fi
golangci-fmt:
glob: "*.go"
run: golangci-lint fmt {staged_files}
stage_fixed: true
golangci-lint:
glob: "*.go"
run: golangci-lint run --new --fast-only
stage_fixed: false
commit-msg:
skip: [ merge, rebase ]
commands:
commit:
run: |
commit_msg_file={1}
commit_msg=$(cat "$commit_msg_file")
# Regex for conventional commits (type(scope?): subject)
regex="^(build|chore|ci|docs|feat|fix|perf|refactor|style|test|sec|wip|revert)(\([a-z0-9\-]+\))?(!)?: .{1,50}"
if ! echo "$commit_msg" | grep -qE "$regex"; then
echo "Error: Commit message does not follow Conventional Commits format."
echo "Format: type(scope?): subject"
echo "Example: feat(login): add remember me option"
exit 1
fi
post-checkout:
commands:
mise:
run: mise -q install