summaryrefslogtreecommitdiff
path: root/external/mit/libcbor/dist/misc/hooks/pre-commit
blob: 2fffd5b1133dde4f7a7490972c5fce3a4784aa9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh

set -e

# Refresh libcbor.org ...
cd docs

if [[ $(git -C .. diff --cached --name-only) == *"index.html.erb"* ]]; then
	echo "The homepage template has been updated, regenerating and checking in the HTML."
	erb index.html.erb > index.html
	git -C .. add $(pwd)/index.html
fi

cd ..

# Run clang-format and add modified files
MODIFIED_UNSTAGED=$(git -C . diff --name-only)
MODIFIED_STAGED=$(git -C . diff --name-only --cached)

./clang-format.sh

git add ${MODIFIED_STAGED}

if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then
  echo "WARNING: Non-staged files were reformatted. Please review and/or add" \
    "them"
fi