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


The following commit(s) were added to refs/heads/master by this push:
     new a6305fbf55 tools/checkpath.sh: check git commit format
a6305fbf55 is described below

commit a6305fbf55ec96887939ae9175be5e128676982e
Author: raiden00pl <raide...@railab.me>
AuthorDate: Tue Aug 26 12:38:42 2025 +0200

    tools/checkpath.sh: check git commit format
    
    check git commit format:
    
    - line length less than 80 for commit title
    - affected subsystem (detecting colon in commit title ":")
    - Signed-off-by line
    - blacklist [VELAPLATO-*, WIP:] string in commit body
    
    Signed-off-by: raiden00pl <raide...@railab.me>
---
 tools/checkpatch.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 3 deletions(-)

diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh
index ae0ebc7c9d..594a139ff2 100755
--- a/tools/checkpatch.sh
+++ b/tools/checkpatch.sh
@@ -44,6 +44,9 @@ isort_warning_once=0
 cvt2utf_warning_once=0
 codespell_config_file_location_was_shown_once=0
 
+# links
+COMMIT_URL="https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md";
+
 usage() {
   echo "USAGE: ${0} [options] [list|-]"
   echo ""
@@ -53,7 +56,7 @@ usage() {
   echo "-u encoding check with cvt2utf (install with: pip install cvt2utf)"
   echo "-r range check only (coupled with -p or -g)"
   echo "-p <patch file names> (default)"
-  echo "-m Change-Id check in commit message (coupled with -g)"
+  echo "-m Check commit message (coupled with -g)"
   echo "-g <commit list>"
   echo "-f <file list>"
   echo "-x format supported files (only .py, requires: pip install black)"
@@ -279,12 +282,61 @@ check_patch() {
 }
 
 check_msg() {
-  while read; do
+  signedoffby_found=0
+  num_lines=0
+  max_line_len=80
+  min_num_lines=5
+
+  first=$(head -n1 <<< "$msg")
+
+  # check for Merge line and remove from parsed string
+  if [[ $first == *Merge* ]]; then
+      msg="$(echo "$msg" | tail -n +2)"
+      first=$(head -n2 <<< "$msg")
+  fi
+
+  while IFS= read -r REPLY; do
     if [[ $REPLY =~  ^Change-Id ]]; then
       echo "Remove Gerrit Change-ID's before submitting upstream"
       fail=1
     fi
-  done
+
+    if [[ $REPLY =~  ^VELAPLATO ]]; then
+      echo "Remove VELAPLATO before submitting upstream"
+      fail=1
+    fi
+
+    if [[ $REPLY =~  ^[Ww][Ii][Pp]: ]]; then
+      echo "Remove WIP before submitting upstream"
+      fail=1
+    fi
+
+    if [[ $REPLY =~  ^Signed-off-by ]]; then
+      signedoffby_found=1
+    fi
+
+    ((num_lines++))
+  done <<< "$msg"
+
+  if ! [[ $first =~  : ]]; then
+    echo "Commit subject missing colon (e.g. 'subsystem: msg')"
+    fail=1
+  fi
+
+  if (( ${#first} > $max_line_len )); then
+    echo "Commit subject too long > $max_line_len"
+    fail=1
+  fi
+
+  if ! [ $signedoffby_found == 1 ]; then
+    echo "Missing Signed-off-by"
+    fail=1
+  fi
+
+  if (( $num_lines < $min_num_lines && $signedoffby_found == 1 )); then
+      echo "Missing git commit message."
+      fail=1
+  fi
 }
 
 check_commit() {
@@ -349,4 +401,12 @@ for arg in $@; do
   $check $arg
 done
 
+
+if [ $fail == 1 ]; then
+    echo "Some checks failed. For contributing guidelines, see:"
+    echo "  $COMMIT_URL"
+else
+    echo "All checks pass."
+fi
+
 exit $fail

Reply via email to