.. | .. |
---|
5 | 5 | DIFF_SUBSET="scripts/.diff_*" |
---|
6 | 6 | DIFF_DOC_ALL="scripts/.diff_all.txt" |
---|
7 | 7 | DIFF_DOC_FIXED="scripts/.diff_fixed.txt" |
---|
| 8 | +LAST_SEVERITY= |
---|
| 9 | +LAST_DOC= |
---|
8 | 10 | |
---|
9 | 11 | function check_doc() |
---|
10 | 12 | { |
---|
.. | .. |
---|
36 | 38 | fi |
---|
37 | 39 | |
---|
38 | 40 | TITLE=`sed -n "/^+## /p" ${DIFF_DOC_ALL} | tr -d " +#"` |
---|
| 41 | + DATE=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $2 }'` |
---|
| 42 | + YEAR=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $2 }' | awk -F "-" '{ print $1 }'` |
---|
| 43 | + MON=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $2 }' | awk -F "-" '{ print $2 }'` |
---|
39 | 44 | FILE=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $3 }'` |
---|
40 | 45 | COMMIT=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $4 }'` |
---|
41 | 46 | SEVERITY=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $5 }'` |
---|
42 | | - HORIZONTAL_LINE=`sed -n "/^+------$/p" ${DIFF_DOC_ALL}` |
---|
| 47 | + END_LINE_3=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '1p'` |
---|
| 48 | + END_LINE_2=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '2p'` |
---|
| 49 | + END_LINE_1=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '3p'` |
---|
| 50 | + HOST_YEAR=`date +%Y` |
---|
| 51 | + HOST_MON=`date +%m` |
---|
43 | 52 | # echo "### ${COMMIT}, ${SEVERITY}, ${TITLE}, ${FILE}" |
---|
44 | 53 | |
---|
45 | 54 | # check blank line after Heading 1 |
---|
46 | 55 | HEADING_1=`sed -n '1p' ${DOC}` |
---|
47 | 56 | if sed -n '2p' ${DOC} | grep -q [a-z,A-Z] ; then |
---|
48 | | - echo "ERROR: ${DOC}: Should reserve blank line after '${HEADING_1}'" |
---|
| 57 | + echo "ERROR: ${DOC}: Please add blank line after '${HEADING_1}'" |
---|
49 | 58 | exit 1 |
---|
50 | 59 | fi |
---|
51 | 60 | |
---|
52 | 61 | # check space |
---|
53 | 62 | if sed -n "/##/p" ${DOC} | grep -v '## [a-z,A-Z]' ; then |
---|
54 | | - echo "ERROR: ${DOC}: Should only 1 space between '#' and word" |
---|
| 63 | + echo "ERROR: ${DOC}: Please only 1 space between '#' and word" |
---|
55 | 64 | exit 1 |
---|
56 | 65 | fi |
---|
57 | 66 | |
---|
58 | 67 | # check new content location |
---|
59 | 68 | if ! git show ${ARG_COMMIT} -1 ${DOC} | grep -q 'Release Note' ; then |
---|
60 | | - echo "ERROR: ${DOC}: Adding new content at the top but not bottom" |
---|
| 69 | + echo "ERROR: ${DOC}: Please add new content at the top but not bottom" |
---|
| 70 | + exit 1 |
---|
| 71 | + fi |
---|
| 72 | + |
---|
| 73 | + # check title |
---|
| 74 | + if grep -Eq '### WARN|### WARNING|### Warning|### warn|### warning' ${DIFF_DOC_ALL} ; then |
---|
| 75 | + echo "ERROR: ${DOC}: Please use '### Warn'" |
---|
| 76 | + exit 1 |
---|
| 77 | + fi |
---|
| 78 | + |
---|
| 79 | + if grep -Eq '### NEW|### new' ${DIFF_DOC_ALL} ; then |
---|
| 80 | + echo "ERROR: ${DOC}: Please use '### New'" |
---|
| 81 | + exit 1 |
---|
| 82 | + fi |
---|
| 83 | + |
---|
| 84 | + if grep -Eq '### FIXED|### fixed' ${DIFF_DOC_ALL} ; then |
---|
| 85 | + echo "ERROR: ${DOC}: Please use '### Fixed'" |
---|
| 86 | + exit 1 |
---|
| 87 | + fi |
---|
| 88 | + |
---|
| 89 | + # check year/month |
---|
| 90 | + if [ "${HOST_YEAR}" != "${YEAR}" ]; then |
---|
| 91 | + echo "ERROR: ${DOC}: '${DATE}' is wrong, the year should be ${HOST_YEAR}" |
---|
| 92 | + exit 1 |
---|
| 93 | + fi |
---|
| 94 | + |
---|
| 95 | + if [ "${HOST_MON}" != "${MON}" ]; then |
---|
| 96 | + echo "ERROR: ${DOC}: '${DATE}' is wrong, the month should be ${HOST_MON}" |
---|
61 | 97 | exit 1 |
---|
62 | 98 | fi |
---|
63 | 99 | |
---|
.. | .. |
---|
65 | 101 | if grep -q $'\t[0-9]' ${DOC} ; then |
---|
66 | 102 | echo "ERROR: ${DOC}: Don't add TAB before index:" |
---|
67 | 103 | grep $'\t[0-9]' ${DOC} |
---|
| 104 | + exit 1 |
---|
| 105 | + fi |
---|
| 106 | + |
---|
| 107 | + # check upper case and line end |
---|
| 108 | + if [ "${LANGUAGE}" == "EN" ] ; then |
---|
| 109 | + if grep -q '^[0-9]\. [a-z]' ${DOC} ; then |
---|
| 110 | + echo "ERROR: ${DOC}: Please use upper case of first word(i.e. \"1. add ..\" => \"1. Add ...\"):" |
---|
| 111 | + grep '^[0-9]\. [a-z]' ${DOC} |
---|
| 112 | + exit 1 |
---|
| 113 | + fi |
---|
| 114 | + |
---|
| 115 | + # check end with '.' |
---|
| 116 | + if sed -n '/^[0-9]\. [A-Z]/p' ${DOC} | grep -q '[^.]$' ; then |
---|
| 117 | + echo "ERROR: ${DOC}: Please end line with '.'" |
---|
| 118 | + grep '^[0-9]\. [A-Z]' ${DOC} | grep '[^.]$' |
---|
| 119 | + exit 1 |
---|
| 120 | + fi |
---|
| 121 | + |
---|
| 122 | + # check Chinese language |
---|
| 123 | + if grep -P '[\x{4e00}-\x{9fa5}]' ${DOC} ; then |
---|
| 124 | + echo "ERROR: ${DOC}: The Chinese language was found" |
---|
| 125 | + exit 1 |
---|
| 126 | + fi |
---|
| 127 | + else |
---|
| 128 | + # check end with '。' |
---|
| 129 | + if sed -n '/^[0-9]\. /p' ${DOC} | grep -q '[^。]$' ; then |
---|
| 130 | + echo "ERROR: ${DOC}: Please end line with '。'" |
---|
| 131 | + grep '^[0-9]\. ' ${DOC} | grep '[^。]$' |
---|
| 132 | + exit 1 |
---|
| 133 | + fi |
---|
| 134 | + fi |
---|
| 135 | + |
---|
| 136 | + # check space after index of 'New' body |
---|
| 137 | + SUM1=`grep '^[0-9]\.' ${DOC} | wc -l` |
---|
| 138 | + SUM2=`grep '^[0-9]\.[[:blank:]]' ${DOC} | wc -l` |
---|
| 139 | + if [ "$SUM1" != "$SUM2" ]; then |
---|
| 140 | + echo "ERROR: ${DOC}: Please add space after index (e.g: '1. ' but not '1.'):" |
---|
| 141 | + grep '^+[0-9]\.' ${DIFF_DOC_ALL} |
---|
68 | 142 | exit 1 |
---|
69 | 143 | fi |
---|
70 | 144 | |
---|
.. | .. |
---|
91 | 165 | for LIST in ${COMMIT}; do |
---|
92 | 166 | CMT=`echo ${LIST} | cut -d : -f 2` |
---|
93 | 167 | if ! git log ${ARG_COMMIT} -1 | grep -q ${CMT} ; then |
---|
94 | | - echo "ERROR: ${DOC}: '${CMT}' is not match in ARG_COMMIT message" |
---|
| 168 | + echo "ERROR: ${DOC}: '${CMT}' is not match in commit message" |
---|
95 | 169 | exit 1 |
---|
96 | 170 | fi |
---|
97 | 171 | |
---|
.. | .. |
---|
117 | 191 | fi |
---|
118 | 192 | |
---|
119 | 193 | # check horizontal line |
---|
120 | | - if [ -z "${HORIZONTAL_LINE}" ]; then |
---|
121 | | - echo "ERROR: ${DOC}: No horizontal line '------' at the last of new content" |
---|
| 194 | + if [ "${END_LINE_2}" != "+------" ]; then |
---|
| 195 | + echo "ERROR: ${DOC}: Please add horizontal line '------' at the last of new content" |
---|
| 196 | + exit 1 |
---|
| 197 | + fi |
---|
| 198 | + if [ "${END_LINE_3}" != "+" ]; then |
---|
| 199 | + echo "ERROR: ${DOC}: Please add blank line before horizontal line '------'" |
---|
| 200 | + exit 1 |
---|
| 201 | + fi |
---|
| 202 | + if [ "${END_LINE_1}" != "+" ]; then |
---|
| 203 | + echo "ERROR: ${DOC}: Please add blank line after horizontal line '------'" |
---|
122 | 204 | exit 1 |
---|
123 | 205 | fi |
---|
124 | 206 | |
---|
.. | .. |
---|
134 | 216 | do |
---|
135 | 217 | EACH_SEVERITY=`echo "${LINE}" | awk -F "|" '{ print $3 }' | tr -d " "` |
---|
136 | 218 | if [ "${EACH_SEVERITY}" != "${SVT_CRITIAL}" -a "${EACH_SEVERITY}" != "${SVT_IMPORTANT}" -a "${EACH_SEVERITY}" != "${SVT_MODERATE}" ]; then |
---|
137 | | - echo "ERROR: ${DOC}: Unknown severity: ${EACH_SEVERITY}" |
---|
| 219 | + if [ -z "${EACH_SEVERITY}" ]; then |
---|
| 220 | + echo "ERROR: ${DOC}: No severity found, please use Table to list what you '### Fixed'" |
---|
| 221 | + else |
---|
| 222 | + echo "ERROR: ${DOC}: Unknown severity: ${EACH_SEVERITY}" |
---|
| 223 | + fi |
---|
138 | 224 | exit 1 |
---|
139 | 225 | fi |
---|
140 | 226 | |
---|
.. | .. |
---|
143 | 229 | TOP_SEVERITY="${EACH_SEVERITY}" |
---|
144 | 230 | elif [ "${TOP_SEVERITY}" == "${SVT_MODERATE}" ]; then |
---|
145 | 231 | if [ "${EACH_SEVERITY}" == "${SVT_CRITIAL}" -o "${EACH_SEVERITY}" == "${SVT_IMPORTANT}" ]; then |
---|
146 | | - TOP_SEVERITY="${EACH_SEVERITY}" |
---|
| 232 | + TOP_SEVERITY="${EACH_SEVERITY}" |
---|
147 | 233 | fi |
---|
148 | 234 | elif [ "${TOP_SEVERITY}" == "${SVT_IMPORTANT}" ]; then |
---|
149 | 235 | if [ "${EACH_SEVERITY}" == "${SVT_CRITIAL}" ]; then |
---|
150 | | - TOP_SEVERITY="${EACH_SEVERITY}" |
---|
| 236 | + TOP_SEVERITY="${EACH_SEVERITY}" |
---|
151 | 237 | fi |
---|
152 | 238 | fi |
---|
153 | 239 | done < ${DIFF_DOC_FIXED} |
---|
154 | 240 | |
---|
155 | 241 | if [ "${SEVERITY}" != "${TOP_SEVERITY}" ]; then |
---|
156 | | - echo "ERROR: ${DOC}: Main severity should be '${TOP_SEVERITY}'" |
---|
| 242 | + echo "ERROR: ${DOC}: Top severity should be '${TOP_SEVERITY}' as it's the highest level of all sub severity" |
---|
157 | 243 | exit 1 |
---|
158 | 244 | fi |
---|
| 245 | + |
---|
| 246 | + # check top severity miss match |
---|
| 247 | + if [ ! -z ${LAST_SEVERITY} ]; then |
---|
| 248 | + if [ "${LAST_SEVERITY}" == "普通" -a "${TOP_SEVERITY}" != "moderate" ]; then |
---|
| 249 | + MISS_MATCH="y" |
---|
| 250 | + elif [ "${LAST_SEVERITY}" == "重要" -a "${TOP_SEVERITY}" != "important" ]; then |
---|
| 251 | + MISS_MATCH="y" |
---|
| 252 | + elif [ "${LAST_SEVERITY}" == "紧急" -a "${TOP_SEVERITY}" != "critical" ]; then |
---|
| 253 | + MISS_MATCH="y" |
---|
| 254 | + elif [ "${LAST_SEVERITY}" == "moderate" -a "${TOP_SEVERITY}" != "普通" ]; then |
---|
| 255 | + MISS_MATCH="y" |
---|
| 256 | + elif [ "${LAST_SEVERITY}" == "important" -a "${TOP_SEVERITY}" != "重要" ]; then |
---|
| 257 | + MISS_MATCH="y" |
---|
| 258 | + elif [ "${LAST_SEVERITY}" == "critical" -a "${TOP_SEVERITY}" != "紧急" ]; then |
---|
| 259 | + MISS_MATCH="y" |
---|
| 260 | + fi |
---|
| 261 | + |
---|
| 262 | + if [ "${MISS_MATCH}" == "y" ]; then |
---|
| 263 | + echo "ERROR: ${DOC}: top Severity is '${SEVERITY}', while ${LAST_DOC}: top Severity is '${LAST_SEVERITY}'" |
---|
| 264 | + echo " Available Severity types are: moderate(普通), important(重要), critical(紧急)" |
---|
| 265 | + exit 1 |
---|
| 266 | + fi |
---|
| 267 | + fi |
---|
| 268 | + |
---|
| 269 | + LAST_SEVERITY="${SEVERITY}" |
---|
| 270 | + LAST_DOC="${DOC}" |
---|
159 | 271 | fi |
---|
160 | 272 | } |
---|
161 | 273 | |
---|
162 | 274 | function check_docs() |
---|
163 | 275 | { |
---|
| 276 | + if git log ${ARG_COMMIT} -1 --name-only | sed -n '5p' | grep -Eq '^ Revert "' ; then |
---|
| 277 | + return; |
---|
| 278 | + fi |
---|
| 279 | + |
---|
164 | 280 | if git log ${ARG_COMMIT} -1 --name-only | grep -Eq '\.bin|\.elf' ; then |
---|
165 | 281 | DOC_CN=`git log ${ARG_COMMIT} -1 --name-only | sed -n "/_CN\.md/p"` |
---|
166 | 282 | DOC_EN=`git log ${ARG_COMMIT} -1 --name-only | sed -n "/_EN\.md/p"` |
---|
.. | .. |
---|
169 | 285 | exit 1 |
---|
170 | 286 | fi |
---|
171 | 287 | |
---|
| 288 | + NUM=`git log ${ARG_COMMIT} -1 --name-only | sed -n "/\.md/p" | wc -l` |
---|
| 289 | + if [ ${NUM} -gt 2 ]; then |
---|
| 290 | + echo "ERROR: More than 2 release note are updated" |
---|
| 291 | + exit 1 |
---|
| 292 | + fi |
---|
| 293 | + |
---|
172 | 294 | if ! which dos2unix > /dev/null 2>&1 ; then |
---|
173 | 295 | echo "ERROR: No 'dos2unix'. Fix by: sudo apt-get install dos2unix" |
---|
174 | 296 | exit 1 |
---|