diff --git a/.astylerc b/.astylerc new file mode 100644 index 0000000..ebd67ec --- /dev/null +++ b/.astylerc @@ -0,0 +1,23 @@ +# Coding standard for MySensors core library (see https://www.mysensors.org/download/contributing) + +# Curly braces should follow "One True Brace Style" format +style=1tbs + +# All control statements ('if', 'for', 'while' etc.) should include curly braces {}. Even one-liners. +add-brackets + +# Tab-character for white space/indentation +indent=tab + +# All lines should be kept at 100 character width or less +max-code-length=100 +break-after-logical + +# Preprocessor blocks should be indented +indent-preproc-block + +# Preprocessor definitions should be indented if linebroken +indent-preproc-define + +# C++ comments should be indented to source level, and not be kept in first column +indent-col1-comments diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2b4a9a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with UTF-8 encoding for every file +[*] +end_of_line = lf +charset = utf-8 + +# For all source code +[*.{c,cpp,h,ino}] +insert_final_newline = true +indent_style = tab +indent_size = 2 + +# Tab indentation also for makefiles +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes index 4635737..415abee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ # Set default behaviour, in case users don't have core.autocrlf set. -* text=auto +* text eol=lf # Explicitly declare text files we want to always be normalized and converted # to native line endings on checkout. diff --git a/MyConfig.h b/MyConfig.h index eec92de..1a1de4b 100644 --- a/MyConfig.h +++ b/MyConfig.h @@ -953,6 +953,7 @@ #define MY_RX_MESSAGE_BUFFER_SIZE #define MY_NODE_LOCK_FEATURE #define MY_REPEATER_FEATURE +#define MY_TRANSPORT_UPLINK_CHECK_DISABLED #define MY_TRANSPORT_DONT_CARE_MODE #define MY_LINUX_SERIAL_GROUPNAME #define MY_IS_SERIAL_PTY diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh new file mode 100644 index 0000000..bb725f0 --- /dev/null +++ b/hooks/pre-commit.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +OPTIONS="--options=.astylerc" + +RETURN=0 +ASTYLE=astyle +if [ $? -ne 0 ]; then + echo "[!] astyle not installed or not in current path. Unable to check source file format policy." >&2 + exit 1 +fi + +FILES=`git diff --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h|ino)$"` +for FILE in $FILES; do + $ASTYLE $OPTIONS < $FILE | cmp -s $FILE - + if [ $? -ne 0 ]; then + echo "[!] $FILE does not respect the agreed coding style." >&2 + RETURN=1 + fi +done + +if [ $RETURN -eq 1 ]; then + echo "" >&2 + echo "Make sure you have run astyle with the following options:" >&2 + echo $OPTIONS >&2 +fi + +exit $RETURN \ No newline at end of file