@@ -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,61 @@ check_patch() {
279282}
280283
281284check_msg () {
282- while read ; do
285+ signedoffby_found=0
286+ num_lines=0
287+ max_line_len=80
288+ min_num_lines=5
289+
290+ first=$( head -n1 <<< " $msg" )
291+
292+ # check for Merge line and remove from parsed string
293+ if [[ $first == * Merge* ]]; then
294+ msg=" $( echo " $msg " | tail -n +2) "
295+ first=$( head -n2 <<< " $msg" )
296+ fi
297+
298+ while IFS= read -r REPLY; do
283299 if [[ $REPLY =~ ^Change-Id ]]; then
284300 echo " Remove Gerrit Change-ID's before submitting upstream"
285301 fail=1
286302 fi
287- done
303+
304+ if [[ $REPLY =~ ^VELAPLATO ]]; then
305+ echo " Remove VELAPLATO before submitting upstream"
306+ fail=1
307+ fi
308+
309+ if [[ $REPLY =~ ^[Ww][Ii][Pp]: ]]; then
310+ echo " Remove WIP before submitting upstream"
311+ fail=1
312+ fi
313+
314+ if [[ $REPLY =~ ^Signed-off-by ]]; then
315+ signedoffby_found=1
316+ fi
317+
318+ (( num_lines++ ))
319+ done <<< " $msg"
320+
321+ if ! [[ $first =~ : ]]; then
322+ echo " Commit subject missing colon (e.g. 'subsystem: msg')"
323+ fail=1
324+ fi
325+
326+ if (( ${# first} > $max_line_len )) ; then
327+ echo " Commit subject too long > $max_line_len "
328+ fail=1
329+ fi
330+
331+ if ! [ $signedoffby_found == 1 ]; then
332+ echo " Missing Signed-off-by"
333+ fail=1
334+ fi
335+
336+ if (( $num_lines < $min_num_lines && $signedoffby_found == 1 )) ; then
337+ echo " Missing git commit message."
338+ fail=1
339+ fi
288340}
289341
290342check_commit () {
@@ -349,4 +401,12 @@ for arg in $@; do
349401 $check $arg
350402done
351403
404+
405+ if [ $fail == 1 ]; then
406+ echo " Some checks failed. For contributing guidelines, see:"
407+ echo " $COMMIT_URL "
408+ else
409+ echo " All checks pass."
410+ fi
411+
352412exit $fail
0 commit comments