-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.75 KB
/
commit-lint.yaml
File metadata and controls
59 lines (49 loc) · 1.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Commit Message Validation
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
jobs:
validate:
name: Validate Commits
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for Chinese characters
run: |
# Get commits to check
if [ "${{ github.event_name }}" == "pull_request" ]; then
COMMITS=$(git rev-list --no-merges ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
else
COMMITS=$(git rev-parse HEAD)
fi
echo "🔍 Checking for Chinese characters in commit messages..."
FAILED=0
for commit in $COMMITS; do
MESSAGE=$(git log -1 --pretty=%B $commit)
SHORT_SHA=$(echo $commit | cut -c1-7)
SUBJECT=$(echo "$MESSAGE" | head -n1)
# Check for Chinese characters (Unicode range 4E00-9FFF)
if echo "$MESSAGE" | grep -P '[\x{4e00}-\x{9fff}]' > /dev/null 2>&1; then
echo "❌ Commit $SHORT_SHA contains Chinese characters: $SUBJECT"
FAILED=1
else
echo "✅ Commit $SHORT_SHA: $SUBJECT"
fi
done
if [ $FAILED -eq 1 ]; then
echo ""
echo "❌ Found commits with Chinese characters. Please use English only."
exit 1
fi
echo ""
echo "✅ No Chinese characters found in commit messages"
- name: Validate Conventional Commits
uses: wagoid/commitlint-github-action@v6
with:
configFile: .commitlintrc.json