From bb26c68f2cb971dd2bb6eaa9916ec2372ebcc646 Mon Sep 17 00:00:00 2001 From: Alexandros Feuerstein <32029275+afeuerstein@users.noreply.github.com> Date: Sat, 24 Jul 2021 15:39:24 +0200 Subject: [PATCH 1/4] minor changes regarding building (#356) * don't enforce any flashing through debug ports --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d02c101..b442fc11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,10 +21,6 @@ if (NOT NRF5_SDK_PATH) message(FATAL_ERROR "The path to the NRF52 SDK must be specified on the command line (add -DNRF5_SDK_PATH=") endif () -if(NOT USE_JLINK AND NOT USE_GDB_CLIENT AND NOT USE_OPENOCD) - set(USE_JLINK true) -endif() - if(USE_JLINK) if (NOT NRFJPROG) message(FATAL_ERROR "the path to the tool nrfjprog must be specified on the command line (add -DNRFJPROG=") From a1a6eae43f5995e21ff3d535094a6350e1031804 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 18 Apr 2021 19:20:16 +0300 Subject: [PATCH 2/4] Added a pre-commit hook that should simplify commiting pre-formatted code --- hooks/README.md | 5 +++++ hooks/pre-commit | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 hooks/README.md create mode 100755 hooks/pre-commit diff --git a/hooks/README.md b/hooks/README.md new file mode 100644 index 00000000..de8fc67b --- /dev/null +++ b/hooks/README.md @@ -0,0 +1,5 @@ +# Git hooks + +This directory contains Git hooks that simplify contributing to this repository. + +You can install them by copying the files into `.git/hooks` in the repository folder or by running `git config --local core.hooksPath hooks` diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 00000000..2e918a17 --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash +for FILE in $(git diff --cached --name-only) +do + if [[ "$FILE" =~ src/[A-Za-z0-9\ \-]+*\.(c|h|cpp|cc)$ ]]; then + echo Autoformatting $FILE with clang-format + clang-format-11 -style=file -i -- $FILE + git add -- $FILE + elif [[ "$FILE" =~ src/(components|displayapp|drivers|heartratetask|logging|systemtask)/.*\.(c|h|cpp|cc)$ ]]; then + echo Autoformatting $FILE with clang-format + clang-format-11 -style=file -i -- $FILE + git add -- $FILE + fi +done From 10ef3a749ede4a27fe162bd730b26fb778ffaa85 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sat, 1 May 2021 20:36:27 +0300 Subject: [PATCH 3/4] Added autodetection for clang-format version --- hooks/pre-commit | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 2e918a17..15961f19 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,13 +1,19 @@ #!/bin/bash +if clang-format --version | grep -q 'version 11\.'; then + CLANG_FORMAT_EXECUTABLE="clang-format" +else + CLANG_FORMAT_EXECUTABLE="clang-format-11" +fi + for FILE in $(git diff --cached --name-only) do if [[ "$FILE" =~ src/[A-Za-z0-9\ \-]+*\.(c|h|cpp|cc)$ ]]; then - echo Autoformatting $FILE with clang-format - clang-format-11 -style=file -i -- $FILE + echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE + $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE git add -- $FILE elif [[ "$FILE" =~ src/(components|displayapp|drivers|heartratetask|logging|systemtask)/.*\.(c|h|cpp|cc)$ ]]; then - echo Autoformatting $FILE with clang-format - clang-format-11 -style=file -i -- $FILE + echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE + $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE git add -- $FILE fi done From 1ba99d242788b50b26b739d571d4866a6c2d0fed Mon Sep 17 00:00:00 2001 From: Avamander Date: Mon, 3 May 2021 14:12:33 +0300 Subject: [PATCH 4/4] Made the pre-commit hook fail explicitly when the executable doesn't exist --- hooks/pre-commit | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hooks/pre-commit b/hooks/pre-commit index 15961f19..5e10aa19 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -5,6 +5,12 @@ else CLANG_FORMAT_EXECUTABLE="clang-format-11" fi +if ! command -v $CLANG_FORMAT_EXECUTABLE &> /dev/null +then + echo $CLANG_FORMAT_EXECUTABLE does not exist, make sure to install it + exit 1 +fi + for FILE in $(git diff --cached --name-only) do if [[ "$FILE" =~ src/[A-Za-z0-9\ \-]+*\.(c|h|cpp|cc)$ ]]; then