Skip to content

Commit c0ed2ac

Browse files
committed
github/workflows/check.yml: Enhance checkpatch for breaking change labels
- Updated the check workflow to conditionally include a '-b' option for breaking change enforcement based on PR labels. - Modified the checkpatch script to support reading commit messages from stdin when using the '-m -g' flags. - Improved usage instructions to clarify the new stdin option for commit message checks. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
1 parent a146303 commit c0ed2ac

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/check.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@ jobs:
4545
cd nuttx
4646
commits="${{ github.event.pull_request.base.sha }}..HEAD"
4747
git log --oneline $commits
48-
echo "../nuttx/tools/checkpatch.sh -c -u -m -g $commits"
49-
../nuttx/tools/checkpatch.sh -c -u -m -g $commits
48+
breaking_opts=""
49+
if echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -e 'any(.[].name; test("breaking change"; "i"))' >/dev/null 2>&1; then
50+
breaking_opts="-b"
51+
fi
52+
echo "../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits"
53+
../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits

tools/checkpatch.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ usage() {
6060
echo "-m Check commit message (coupled with -g)"
6161
echo "-b Enforce breaking change format when checking commit message (requires -m -g; use when PR has breaking change label)"
6262
echo "-g <commit list>"
63+
echo " Use --stdin as the only argument with -m -g to read commit message from stdin (message-only check, no patch/diff)."
6364
echo "-f <file list>"
6465
echo "-x format supported files (only .py, requires: pip install black)"
6566
echo "- read standard input mainly used by git pre-commit hook as below:"
@@ -286,6 +287,7 @@ check_patch() {
286287
check_msg() {
287288
signedoffby_found=0
288289
num_lines=0
290+
# Commit subject line length limit (50/72 are common; NuttX uses 80)
289291
max_line_len=80
290292
min_num_lines=5
291293
breaking_change_found=0
@@ -420,6 +422,9 @@ while [ ! -z "$1" ]; do
420422
-h )
421423
usage 0
422424
;;
425+
--stdin )
426+
break
427+
;;
423428
-p )
424429
check=check_patch
425430
;;
@@ -437,7 +442,12 @@ while [ ! -z "$1" ]; do
437442
done
438443

439444
for arg in $@; do
440-
$check $arg
445+
if [ "$arg" = "--stdin" ] && [ "$check" = "check_commit" ]; then
446+
msg=$(cat)
447+
check_msg <<< "$msg"
448+
else
449+
$check $arg
450+
fi
441451
done
442452

443453
if [ $fail == 1 ]; then

0 commit comments

Comments
 (0)