blob: e1745b1f0f5c5b4d94bbe35c819b8e55c67b0f6f (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/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 -d `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 -d `pwd`
EOF
chmod +x .git/hooks/pre-commit
fi
;;
hg)
if [ -e .hg/hgrc ] && grep "^\[hooks\]" .hg/hgrc; then
if ! grep -q "etckeeper pre-commit" .hg/hgrc; then
echo "etckeeper warning: [hooks] section in .hg/hgrc needs to be manually modified to run: etckeeper pre-commit -d `pwd`" >&2
fi
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 -d `pwd`
EOF
fi
;;
darcs)
if [ -e _darcs/prefs/defaults ]; then
if ! ( grep -q "record prehook etckeeper pre-commit" _darcs/prefs/defaults &&
grep -q "whatsnew prehook etckeeper pre-commit" _darcs/prefs/defaults ); then
echo "etckeeper warning: _darcs/prefs/defaults needs to be manually modified to run: etckeeper pre-commit -d `pwd`" >&2
fi
else
cat >_darcs/prefs/defaults <<EOF
record prehook etckeeper pre-commit -d `pwd`
record run-prehook
whatsnew prehook etckeeper pre-commit -d `pwd`
whatsnew run-prehook
EOF
fi
;;
esac
|