#!/bin/bash # Yes, this script can be improved immensly... cd .. result=0 echo "No subjects are of invalid size
" > too_long_subjects.txt echo "No subjects with leading lower case characters
" > leading_lowercases.txt echo "No subjects with trailing periods
" > trailing_periods.txt echo "No body lines are too wide
" > too_long_body_lines.txt echo "No keywords are missing in keywords.txt
" > missing_keywords.txt echo "No occurences of the deprecated boolean data type
" >> booleans.txt too_long_subjects=`awk 'length > 72' subjects.txt` if [ -n "$too_long_subjects" ]; then echo "Commit subjects that are too wide (>72 characters):" > too_long_subjects.txt echo "$too_long_subjects" >> too_long_subjects.txt sed -i -e 's/$/
/' too_long_subjects.txt result=1 fi leading_lowercases=`awk '/^[[:lower:][:punct:]]/' subjects.txt` if [ -n "$leading_lowercases" ]; then echo "Commit subjects with leading lowercase characters:" > leading_lowercases.txt echo "$leading_lowercases" >> leading_lowercases.txt sed -i -e 's/$/
/' leading_lowercases.txt result=1 fi trailing_periods=`awk '/(\.)$/' subjects.txt` if [ -n "$trailing_periods" ]; then echo "Commit subjects with trailing periods:" > trailing_periods.txt echo "$trailing_periods" >> trailing_periods.txt sed -i -e 's/$/
/' trailing_periods.txt result=1 fi too_long_body_lines=`awk 'length > 72' bodies.txt` if [ -n "$too_long_body_lines" ]; then echo "Body lines that are too wide (>72 characters):" > too_long_body_lines.txt echo "$too_long_body_lines" >> too_long_body_lines.txt sed -i -e 's/$/
/' too_long_body_lines.txt result=1 fi missing_keywords=$(for keyword in $(grep -A999 '#if DOXYGEN' MyConfig.h | grep -B999 '#endif' | grep '#define' | awk '{ print $2 '} | grep -e '^MY_'); do grep -q $keyword keywords.txt || echo $keyword; done) if [ -n "$missing_keywords" ]; then echo "Keywords that are missing from keywords.txt:" > missing_keywords.txt echo "$missing_keywords" >> missing_keywords.txt sed -i -e 's/$/
/' missing_keywords.txt result=1 fi # Evaluate if there exists booleans in the code tree (not counting this file) if git grep -q boolean -- `git ls-files | grep -v butler.sh`; then echo "You have added at least one occurence of the deprecated boolean data type. Please use bool instead.
" > booleans.txt result=1 fi printf "%s" "" > butler.html echo "Greetings Sir! Here is my evaluation of your pull request:
" >> butler.html awk 'FNR==1{print "
"}1' too_long_subjects.txt leading_lowercases.txt trailing_periods.txt too_long_body_lines.txt missing_keywords.txt booleans.txt >> butler.html echo "
" >> butler.html if [ $result -ne 0 ]; then echo "I am afraid there are some issues with your commit messages and/or use of keywords.
" >> butler.html echo "I highly recommend reading this guide for tips on how to write a good commit message.
" >> butler.html echo "More specifically, MySensors have some code contribution guidelines that I am afraid all contributers need to follow.
" >> butler.html echo "
" >> butler.html echo "I can help guide you in how to change the commit message for a single-commit pull request:
" >> butler.html echo "git checkout <your_branch>
" >> butler.html echo "git commit --amend
" >> butler.html echo "git push origin HEAD:<your_branch_on_github> -f
" >> butler.html echo "
" >> butler.html echo "To change the commit messages for a multiple-commit pull request:
" >> butler.html echo "git checkout <your_branch>
" >> butler.html echo "git rebase -i <sha_of_parent_to_the_earliest_commit_you_want_to_change>
" >> butler.html echo "Replace \"pick\" with \"r\" or \"reword\" on the commits you need to change message for
" >> butler.html echo "git push origin HEAD:<your_branch_on_github> -f
" >> butler.html echo "
" >> butler.html fi # Evaluate coding style astyle --options=.mystools/astyle/config/style.cfg -nq --recursive "*.h" "*.c" "*.cpp" git diff > restyling.patch if [ -s restyling.patch ]; then echo "I am afraid your coding style is not entirely in line with the MySensors preffered style.
A mail with a patch has been sent to you that, if applied to your PR, will make it follow the MySensors coding standards.

" >> butler.html echo "You can apply the patch using:
" >> butler.html echo "git apply restyling.patch
" >> butler.html echo "
" >> butler.html result=1 else echo "This commit is meeting the coding standards, well done Sir!
" >> butler.html echo "
" >> butler.html rm restyling.patch fi if [ $result -ne 0 ]; then echo "If you have any questions, please first read the code contribution guidelines.
" >> butler.html echo "If you disagree to this, please discuss it in the GitHub pull request thread.
" >> butler.html echo "
" >> butler.html fi echo "Yours sincerely, The Butler, serving the MySensors community
" >> butler.html printf "%s" "" >> butler.html exit $result