[AC-INIT] 修改初始配置文件 #14

Merged
MerCry merged 2 commits from setup-gate into main 2026-02-24 03:58:45 +00:00
1 changed files with 19 additions and 5 deletions
Showing only changes of commit 5bc424d441 - Show all commits

View File

@ -45,14 +45,28 @@ jobs:
- name: 1. Commit Message Check
shell: sh
run: |
set -eu
echo "Checking commit messages for [AC-...] or [TASK-...] (range: refs/remotes/origin/main..HEAD)"
# refs/remotes/origin/main is fetched in the checkout step
git log --no-merges --format=%B refs/remotes/origin/main..HEAD | cat
if git log --no-merges --format=%B refs/remotes/origin/main..HEAD | grep -Eq '\[(AC|TASK)-'; then
range="refs/remotes/origin/main..HEAD"
# Ignore tool-generated merge commits and filter out merge titles
msgs="$(git log --format=%B --no-merges "$range" || true)"
if [ -z "${msgs}" ]; then
echo "WARNING: No non-merge commits found in range ${range}. Skipping commit message gate."
exit 0
fi
echo "$msgs" | cat
# Drop lines like "Merge branch ..." just in case
filtered="$(echo "$msgs" | grep -Ev '^(Merge( branch)? |Merge pull request )' || true)"
if echo "$filtered" | grep -Eq '\[(AC|TASK)-'; then
echo "OK: Found [AC-...] or [TASK-...] in PR commits"
else
echo "ERROR: At least one commit message in the PR must contain [AC-...] or [TASK-...]"
echo "ERROR: At least one non-merge commit message in the PR must contain [AC-...] or [TASK-...]"
exit 1
fi