File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Check that commits with 20+ lines changed include a non-empty body.
3+ # Skips merge commits.
4+ #
5+ # Usage: check-commit-body.sh <base-sha>
6+ set -euo pipefail
7+
8+ base=" ${1:? Usage: check-commit-body.sh <base-sha>} "
9+ errors=0
10+
11+ for commit in $( git log --no-merges --format=%H " ${base} ..HEAD" ) ; do
12+ short=$( git log -1 --format=%h " $commit " )
13+ body=$( git log -1 --format=%b " $commit " )
14+
15+ lines_changed=$( git diff-tree --no-commit-id --numstat -r " $commit " \
16+ | awk ' { s += $1 + $2 } END { print s+0 }' )
17+ body_trimmed=$( echo " $body " | sed ' /^$/d' | head -1)
18+
19+ if [ " $lines_changed " -ge 20 ] && [ -z " $body_trimmed " ]; then
20+ echo " ::error::Commit $short : $lines_changed lines changed but no commit body."
21+ echo " Commits with 20+ lines changed should include a description."
22+ errors=$(( errors + 1 ))
23+ fi
24+ done
25+
26+ if [ " $errors " -gt 0 ]; then
27+ echo " Found $errors commit(s) missing a body."
28+ exit 1
29+ fi
30+
31+ echo " All large commits have a body."
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Check that no fixup/squash/WIP commits remain in the PR.
3+ # Skips merge commits.
4+ #
5+ # Usage: check-no-fixup.sh <base-sha>
6+ set -euo pipefail
7+
8+ base=" ${1:? Usage: check-no-fixup.sh <base-sha>} "
9+ errors=0
10+
11+ for commit in $( git log --no-merges --format=%H " ${base} ..HEAD" ) ; do
12+ subject=$( git log -1 --format=%s " $commit " )
13+ short=$( git log -1 --format=%h " $commit " )
14+
15+ case " $subject " in
16+ fixup!* |squash!* |WIP:* |WIP\ * |wip:* |wip\ * )
17+ echo " ::error::Commit $short : fixup/squash/WIP commits must be cleaned up before merge."
18+ echo " Title: $subject "
19+ errors=$(( errors + 1 ))
20+ ;;
21+ esac
22+ done
23+
24+ if [ " $errors " -gt 0 ]; then
25+ echo " Found $errors fixup/WIP commit(s)."
26+ exit 1
27+ fi
28+
29+ echo " No fixup/squash/WIP commits found."
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Check that commit titles do not exceed 80 characters.
3+ # Skips merge commits.
4+ #
5+ # Usage: check-title-length.sh <base-sha>
6+ set -euo pipefail
7+
8+ base=" ${1:? Usage: check-title-length.sh <base-sha>} "
9+ errors=0
10+
11+ for commit in $( git log --no-merges --format=%H " ${base} ..HEAD" ) ; do
12+ subject=$( git log -1 --format=%s " $commit " )
13+ short=$( git log -1 --format=%h " $commit " )
14+
15+ title_len=${# subject}
16+ if [ " $title_len " -gt 80 ]; then
17+ echo " ::error::Commit $short : title is $title_len chars (max 80)."
18+ echo " Title: $subject "
19+ errors=$(( errors + 1 ))
20+ fi
21+ done
22+
23+ if [ " $errors " -gt 0 ]; then
24+ echo " Found $errors title length error(s)."
25+ exit 1
26+ fi
27+
28+ echo " All commit titles are within 80 characters."
Original file line number Diff line number Diff line change 2727 - uses : actions/checkout@v6
2828 with :
2929 fetch-depth : 0
30- - name : Verify commit message quality
30+ - name : Check title length
3131 run : >
32- .github/scripts/pr-hygiene/check-commit-messages.sh
32+ .github/scripts/pr-hygiene/check-title-length.sh
33+ "${{ github.event.pull_request.base.sha }}"
34+ - name : Check no fixup/WIP commits
35+ run : >
36+ .github/scripts/pr-hygiene/check-no-fixup.sh
37+ "${{ github.event.pull_request.base.sha }}"
38+ - name : Check commit body on large changes
39+ run : >
40+ .github/scripts/pr-hygiene/check-commit-body.sh
3341 "${{ github.event.pull_request.base.sha }}"
You can’t perform that action at this time.
0 commit comments