xref: /netbsd-src/external/mit/libcbor/dist/misc/hooks/pre-commit (revision 5dd36a3bc8bf2a9dec29ceb6349550414570c447)
1#!/bin/sh
2
3set -e
4
5# Refresh libcbor.org ...
6cd docs
7
8if [[ $(git -C .. diff --cached --name-only) == *"index.html.erb"* ]]; then
9	echo "The homepage template has been updated, regenerating and checking in the HTML."
10	erb index.html.erb > index.html
11	git -C .. add $(pwd)/index.html
12fi
13
14cd ..
15
16# Run clang-format and add modified files
17MODIFIED_UNSTAGED=$(git -C . diff --name-only)
18MODIFIED_STAGED=$(git -C . diff --name-only --cached)
19
20./clang-format.sh
21
22git add ${MODIFIED_STAGED}
23
24if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then
25  echo "WARNING: Non-staged files were reformatted. Please review and/or add" \
26    "them"
27fi
28
29
30