forked from kevinchappell/formBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
43 lines (36 loc) · 1.29 KB
/
lefthook.yml
File metadata and controls
43 lines (36 loc) · 1.29 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
# Lefthook configuration
# See: https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
pre-commit:
# Skip in CI
skip:
- run: test "$CI" = "true"
reason: "Skipping pre-commit hook in CI"
commands:
# Validate branch name
branch-name-check:
run: |
LOCAL_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
VALID_BRANCH_NAME_REGEX="^(feat|chore|fix)\/[0-9]{1,6}(-[a-z0-9._-]{1,40})?$"
matches=$(echo "$LOCAL_BRANCH" | grep -iE "$VALID_BRANCH_NAME_REGEX" | wc -l)
if [ $matches -eq 0 ]; then
echo "There is something wrong with your branch name."
echo "Branch names in this project must adhere to the following pattern:"
echo "--> Regex: $VALID_BRANCH_NAME_REGEX"
echo "--> Examples: feat/1234-example or chore/123"
echo ""
echo "Your commit was rejected, please rename your branch to a valid name and try again."
exit 1
fi
stage_fixed: false
# Run lint-staged
lint-staged:
run: npm run pre-commit
stage_fixed: true
commit-msg:
# Skip in CI
skip:
- run: test "$CI" = "true"
reason: "Skipping commit-msg hook in CI"
commands:
commitlint:
run: npx --no -- commitlint --edit $LEFTHOOK_GIT_PARAMS