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