-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlefthook.yml
32 lines (29 loc) · 1.15 KB
/
lefthook.yml
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
pre-commit:
commands:
protect-branches:
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD)
CHANGED_FILES=$(git diff --cached --name-only)
if [ "$BRANCH" = "main" ]; then
echo $CHANGED_FILES
for file in $CHANGED_FILES; do
if [[ ! "$file" =~ ^(.github/workflows/|lefthook.yml|CHANGELOG.md|package.json|dist/|scripts/publish.sh|version.json|.vscode/) ]]; then
echo "❌ main과 storybook 브랜치에는 직접 커밋할 수 없습니다. PR을 통한 병합을 진행해주세요."
exit 1
fi
done
fi
pre-push:
commands:
protect-push:
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD)
CHANGED_FILES=$(git diff --cached --name-only)
if [ "$BRANCH" = "main" ]; then
for file in $CHANGED_FILES; do
if [[ ! "$file" =~ ^(package.json|dist/|scripts/publish.sh|version.json|.vscode/|CHANGELOG.md) ]]; then
echo "❌ protected 브랜치에는 직접 push할 수 없습니다. PR을 통한 병합을 진행해주세요."
exit 1
fi
done
fi