Skip to content

Commit a38e737

Browse files
hudeng-goBLumia
authored andcommitted
feat: add AI co-author pattern check for PR and commits
git commit的提交规范,不允许在gith commit当中包含ai agent相关的co-author Log:
1 parent 89db479 commit a38e737

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/commitlint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,30 @@ jobs:
1212
ref: ${{ github.event.pull_request.head.sha }}
1313
fetch-depth: 0
1414

15+
- name: check PR description for AI co-author pattern
16+
shell: bash
17+
run: |
18+
BLOCKED_PATTERN='Co-authored-by:.*ai|Co-authored-by:.*agent|Co-authored-by:.*copilot|Co-authored-by:.*llm|Co-authored-by:.*gpt'
19+
PR_BODY="${{ github.event.pull_request.body }}"
20+
if echo "${PR_BODY}" | grep -Eiq "${BLOCKED_PATTERN}"; then
21+
echo "FAIL: PR description contains blocked co-author AI pattern." >&2
22+
echo "Blocked pattern: ${BLOCKED_PATTERN}" >&2
23+
echo "Please remove AI-generated co-author lines from PR description." >&2
24+
exit 1
25+
fi
26+
echo "PASS: PR description does not contain blocked AI co-author pattern."
27+
28+
- name: check commit messages for AI co-author pattern
29+
shell: bash
30+
run: |
31+
BLOCKED_PATTERN='Co-authored-by:.*ai|Co-authored-by:.*agent|Co-authored-by:.*copilot|Co-authored-by:.*llm|Co-authored-by:.*gpt'
32+
COMMIT_MSGS=$(git log --format=%B ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} 2>/dev/null || true)
33+
if [[ -n "${COMMIT_MSGS}" ]] && echo "${COMMIT_MSGS}" | grep -Eiq "${BLOCKED_PATTERN}"; then
34+
echo "FAIL: Commit messages contain blocked co-author AI pattern." >&2
35+
echo "Blocked pattern: ${BLOCKED_PATTERN}" >&2
36+
exit 1
37+
fi
38+
echo "PASS: Commit messages do not contain blocked AI co-author pattern."
39+
1540
- name: Call Conventional Commits Checker
1641
uses: linuxdeepin/action-conventionalcommits-checker@master

0 commit comments

Comments
 (0)