summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBui Nguyen Quoc Thanh <49302843+thanhbnq@users.noreply.github.com>2022-12-14 16:09:23 +0700
committerGitHub <noreply@github.com>2022-12-14 10:09:23 +0100
commit198715eb7d606515c1dd22187080cae483480849 (patch)
tree8c589931dd773e73c46c7510abf5e4de172b02ee /scripts
parent4857ffca487d551564dfee41d1ad89f2db9ac1af (diff)
downloadDLT-daemon-198715eb7d606515c1dd22187080cae483480849.tar.gz
Updates for Coding Styles (#425)
- Remove uncrustify - Use clang-format and pre-commit hooks script - Update README accordingly Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/pre-commit.sample28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/pre-commit.sample b/scripts/pre-commit.sample
new file mode 100755
index 0000000..5324c3b
--- /dev/null
+++ b/scripts/pre-commit.sample
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+gitclangformat=$(which git-clang-format)
+
+if [ "$gitclangformat" == "" ]
+then
+ gitclangformat=$(find /usr/bin/ -name "git-clang-format*")
+fi
+
+against=`git rev-parse --verify HEAD 2>&1`
+
+if [ $against == "" ]
+then
+ # Initial commit: diff against an empty tree object
+ against=5394c6fa5bf40d9bc8619026cbc4c306211a8499
+fi
+
+$gitclangformat $against -f -q
+
+if [ $? != 0 ]
+then
+ echo "Format error!"
+ echo "Use git clang-format"
+ exit 1
+fi
+
+# Now update format changes and commit
+git add $(git diff --name-only --cached)