@@ -44,6 +44,9 @@ isort_warning_once=0
4444cvt2utf_warning_once=0
4545codespell_config_file_location_was_shown_once=0
4646
47+ # links
48+ COMMIT_URL=" https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md"
49+
4750usage () {
4851 echo " USAGE: ${0} [options] [list|-]"
4952 echo " "
@@ -53,7 +56,7 @@ usage() {
5356 echo " -u encoding check with cvt2utf (install with: pip install cvt2utf)"
5457 echo " -r range check only (coupled with -p or -g)"
5558 echo " -p <patch file names> (default)"
56- echo " -m Change-Id check in commit message (coupled with -g)"
59+ echo " -m Check commit message (coupled with -g)"
5760 echo " -g <commit list>"
5861 echo " -f <file list>"
5962 echo " -x format supported files (only .py, requires: pip install black)"
@@ -279,12 +282,59 @@ check_patch() {
279282}
280283
281284check_msg () {
285+ first=$( head -n1 <<< " $msg" )
286+ signedoffby_found=0
287+ num_lines=0
288+ max_line_len=72
289+ min_num_lines=5
290+
282291 while read ; do
283292 if [[ $REPLY =~ ^Change-Id ]]; then
284293 echo " Remove Gerrit Change-ID's before submitting upstream"
285294 fail=1
286295 fi
296+
297+ if [[ $REPLY =~ ^VELAPLATO ]]; then
298+ echo " Remove VELAPLATO before submitting upstream"
299+ fail=1
300+ fi
301+
302+ if [[ $REPLY =~ ^[Ww][Ii][Pp]: ]]; then
303+ echo " Remove WIP before submitting upstream"
304+ fail=1
305+ fi
306+
307+ if [[ $REPLY =~ ^Signed-off-by ]]; then
308+ signedoffby_found=1
309+ fi
310+
311+ if (( ${# REPLY} > $max_line_len )) ; then
312+ echo " Commit message too long > $max_line_len "
313+ fail=1
314+ fi
315+
316+ (( num_lines++ ))
287317 done
318+
319+ if ! [[ $first =~ : ]]; then
320+ echo " Commit subject missing colon (e.g. 'subsystem: msg')"
321+ fail=1
322+ fi
323+
324+ if (( ${# first} > $max_line_len )) ; then
325+ echo " Commit subject too long > $max_line_len "
326+ fail=1
327+ fi
328+
329+ if ! [ $signedoffby_found == 1 ]; then
330+ echo " Missing Signed-off-by"
331+ fail=1
332+ fi
333+
334+ if (( $num_lines < $min_num_lines && $signedoffby_found == 1 )) ; then
335+ echo " Missing git commit message."
336+ fail=1
337+ fi
288338}
289339
290340check_commit () {
@@ -349,4 +399,12 @@ for arg in $@; do
349399 $check $arg
350400done
351401
402+
403+ if [ $fail == 1 ]; then
404+ echo " Some checks failed. For contributing guidelines, see:"
405+ echo " $COMMIT_URL "
406+ else
407+ echo " All checks pass."
408+ fi
409+
352410exit $fail
0 commit comments