From 958c7bcf9aada77568105744cbc757f168c85981 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Wed, 12 Apr 2023 09:09:01 +0000 Subject: [PATCH] scripts: checkpatch: Fix year get and improve error message Signed-off-by: Joseph Chen Change-Id: I55c19bea1a2e96b8b8ad80acb4b8551fd063a95b --- scripts/checkpatch.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/checkpatch.sh b/scripts/checkpatch.sh index ec7cc0fd..a3991a82 100755 --- a/scripts/checkpatch.sh +++ b/scripts/checkpatch.sh @@ -46,25 +46,25 @@ function check_doc() END_LINE_3=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '1p'` END_LINE_2=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '2p'` END_LINE_1=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '3p'` - HOST_YEAR=`date | awk '{ print $6 }'` + HOST_YEAR=`date +%Y` # echo "### ${COMMIT}, ${SEVERITY}, ${TITLE}, ${FILE}" # check blank line after Heading 1 HEADING_1=`sed -n '1p' ${DOC}` if sed -n '2p' ${DOC} | grep -q [a-z,A-Z] ; then - echo "ERROR: ${DOC}: Should reserve blank line after '${HEADING_1}'" + echo "ERROR: ${DOC}: Please add blank line after '${HEADING_1}'" exit 1 fi # check space if sed -n "/##/p" ${DOC} | grep -v '## [a-z,A-Z]' ; then - echo "ERROR: ${DOC}: Should only 1 space between '#' and word" + echo "ERROR: ${DOC}: Please only 1 space between '#' and word" exit 1 fi # check new content location if ! git show ${ARG_COMMIT} -1 ${DOC} | grep -q 'Release Note' ; then - echo "ERROR: ${DOC}: Adding new content at the top but not bottom" + echo "ERROR: ${DOC}: Please add new content at the top but not bottom" exit 1 fi @@ -174,15 +174,15 @@ function check_doc() # check horizontal line if [ "${END_LINE_2}" != "+------" ]; then - echo "ERROR: ${DOC}: No horizontal line '------' found at the last of new content" + echo "ERROR: ${DOC}: Please add horizontal line '------' at the last of new content" exit 1 fi if [ "${END_LINE_3}" != "+" ]; then - echo "ERROR: ${DOC}: No blank line found before horizontal line '------'" + echo "ERROR: ${DOC}: Please add blank line before horizontal line '------'" exit 1 fi if [ "${END_LINE_1}" != "+" ]; then - echo "ERROR: ${DOC}: No blank line found after horizontal line '------'" + echo "ERROR: ${DOC}: Please add blank line after horizontal line '------'" exit 1 fi