blob: 5c6325448801a5f9af829addefacae55ba819914 (
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
30
31
32
|
#!/bin/sh
set -e
case "$VCS" in
git)
if [ -x .git/hooks/pre-commit ]; then
if ! grep -q "etckeeper pre-commit" .git/hooks/pre-commit; then
echo "etckeeper warning: .git/hooks/pre-commit needs to be manually modified to run: etckeeper pre-commit `pwd`" >&2
fi
else
cat >.git/hooks/pre-commit <<EOF
#!/bin/sh
# pre-commit hook for etckeeper, to store metadata and do sanity checks
set -e
etckeeper pre-commit `pwd`
EOF
chmod +x .git/hooks/pre-commit
fi
;;
hg)
if [ -e .hg/hgrc ] && grep "^\[hooks\]" .hg/hgrc; then
echo "etckeeper warning: [hooks] section in .hg/hgrc needs to be manually modified to run: etckeeper pre-commit `pwd`" >&2
else
touch .hg/hgrc
cat >>.hg/hgrc <<EOF
[hooks]
# pre-commit hook for etckeeper, to store metadata and do sanity checks
precommit = etckeeper pre-commit `pwd`
EOF
fi
;;
esac
|