@@ -17,6 +17,13 @@ cd "$RIOTBASE" || exit
1717
1818EXIT_CODE=0
1919
20+ # Keywords that should trigger the commit message check and prevent an accidental
21+ # merge of something not meant to be merged.
22+ # The pretty-print format of the commit messages is always the following:
23+ # `a5e4f038b8 commit message`
24+ # This has to be reflected in the RegEx matching pattern.
25+ NOMERGE_KEYWORD_FILE=" $( dirname " $0 " ) /no_merge_keywords"
26+
2027github_annotate_setup
2128
2229if tput colors & > /dev/null && [ " $( tput colors) " -ge 8 ]; then
3340 RIOT_MASTER=" master"
3441fi
3542
36- keyword_filter () {
37- grep -i \
38- -e " ^ [0-9a-f]\+ .\{0,2\}SQUASH" \
39- -e " ^ [0-9a-f]\+ .\{0,2\}FIX" \
40- -e " ^ [0-9a-f]\+ .\{0,2\}REMOVE *ME" \
41- -e " ^ [0-9a-f]\+ .\{0,2\}Update"
42- }
43-
44- SQUASH_COMMITS=" $( git log " $( git merge-base HEAD " ${RIOT_MASTER} " ) " ...HEAD --pretty=format:" %h %s" | \
45- keyword_filter) "
43+ SQUASH_COMMITS=" $( git log " $( git merge-base HEAD " ${RIOT_MASTER} " ) " ...HEAD --pretty=format:" %h %s" | \
44+ grep -i -f " ${NOMERGE_KEYWORD_FILE} " ) "
4645
4746if [ -n " ${SQUASH_COMMITS} " ]; then
4847 if github_annotate_is_on; then
49- echo " ${SQUASH_COMMITS} " | while read -r commit; do
50- ANNOTATION=" Commit needs to be squashed: \" ${commit} \" "
51- ANNOTATION=" ${ANNOTATION} \n\nPLEASE ONLY SQUASH WHEN ASKED BY A "
48+ ANNOTATION=" "
49+ while read -r commit; do
50+ ANNOTATION=" ${ANNOTATION} Commit needs to be squashed or contains a no-merge keyword: \" ${commit} \" \n"
51+ done < <( echo " ${SQUASH_COMMITS} " )
52+
53+ if [ -n " ${ANNOTATION} " ]; then
54+ ANNOTATION=" ${ANNOTATION} \nPLEASE ONLY SQUASH WHEN ASKED BY A "
5255 ANNOTATION=" ${ANNOTATION} MAINTAINER!"
5356 ANNOTATION=" ${ANNOTATION} \nSee: "
54- ANNOTATION=" ${ANNOTATION} https://github.com/RIOT-OS/RIOT/blob/master/CONTRIBUTING.md#squash-commits-after-review"
57+ ANNOTATION=" ${ANNOTATION} https://github.com/RIOT-OS/RIOT/blob/master/CONTRIBUTING.md#squash-commits-after-review\n "
5558 github_annotate_error_no_file " ${ANNOTATION} "
56- done
59+ fi
5760 else
58- echo -e " ${CERROR} Pull request needs squashing:${CRESET} " 1>&2
59- echo -e " ${SQUASH_COMMITS} "
61+ echo -e " ${CERROR} Pull request needs squashing or contains no-merge keywords:${CRESET} " 1>&2
62+ while IFS= read -r line; do
63+ echo -e " ${line} "
64+ done <<< " ${SQUASH_COMMITS}"
6065 fi
6166 EXIT_CODE=1
6267fi
0 commit comments