This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 1d514dab1a03e50ae8f011b507b081a2f9e3eaca Author: Arjav Patel <[email protected]> AuthorDate: Tue Feb 24 11:20:04 2026 +0530 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 <[email protected]> --- .github/workflows/check.yml | 8 ++++++-- tools/checkpatch.sh | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7f7ecbaf836..422fc7927af 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -45,5 +45,9 @@ jobs: cd nuttx commits="${{ github.event.pull_request.base.sha }}..HEAD" git log --oneline $commits - echo "../nuttx/tools/checkpatch.sh -c -u -m -g $commits" - ../nuttx/tools/checkpatch.sh -c -u -m -g $commits + breaking_opts="" + if echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -e 'any(.[].name; test("breaking change"; "i"))' >/dev/null 2>&1; then + breaking_opts="-b" + fi + echo "../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits" + ../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index bec4bae7605..f2865aaa0e5 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -60,6 +60,7 @@ usage() { echo "-m Check commit message (coupled with -g)" echo "-b Enforce breaking change format when checking commit message (requires -m -g; use when PR has breaking change label)" echo "-g <commit list>" + echo " Use --stdin as the only argument with -m -g to read commit message from stdin (message-only check, no patch/diff)." echo "-f <file list>" echo "-x format supported files (only .py, requires: pip install black)" echo "- read standard input mainly used by git pre-commit hook as below:" @@ -286,6 +287,7 @@ check_patch() { check_msg() { signedoffby_found=0 num_lines=0 + # Commit subject line length limit (50/72 are common; NuttX uses 80) max_line_len=80 min_num_lines=5 breaking_change_found=0 @@ -420,6 +422,9 @@ while [ ! -z "$1" ]; do -h ) usage 0 ;; + --stdin ) + break + ;; -p ) check=check_patch ;; @@ -437,7 +442,12 @@ while [ ! -z "$1" ]; do done for arg in $@; do - $check $arg + if [ "$arg" = "--stdin" ] && [ "$check" = "check_commit" ]; then + msg=$(cat) + check_msg <<< "$msg" + else + $check $arg + fi done if [ $fail == 1 ]; then
