Mercurial > hgbook
comparison en/examples/ch09/hook.ws @ 821:88828b784971
Add more complex example hook
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 28 Apr 2009 23:10:43 -0700 |
parents | en/examples/hook.ws@e67251ac336f |
children |
comparison
equal
deleted
inserted
replaced
820:3edacbff2b43 | 821:88828b784971 |
---|---|
1 #!/bin/bash | |
2 | |
3 hg init a | |
4 cd a | |
5 echo '[hooks]' > .hg/hgrc | |
6 echo "pretxncommit.whitespace = hg export tip | (! egrep -q '^\\+.*[ \\t]$')" >> .hg/hgrc | |
7 | |
8 #$ name: simple | |
9 | |
10 cat .hg/hgrc | |
11 echo 'a ' > a | |
12 hg commit -A -m 'test with trailing whitespace' | |
13 echo 'a' > a | |
14 hg commit -A -m 'drop trailing whitespace and try again' | |
15 | |
16 #$ name: | |
17 | |
18 echo '[hooks]' > .hg/hgrc | |
19 echo "pretxncommit.whitespace = .hg/check_whitespace.py" >> .hg/hgrc | |
20 cp $EXAMPLE_DIR/ch09/check_whitespace.py.lst .hg/check_whitespace.py | |
21 chmod +x .hg/check_whitespace.py | |
22 | |
23 #$ name: better | |
24 | |
25 cat .hg/hgrc | |
26 echo 'a ' >> a | |
27 hg commit -A -m 'add new line with trailing whitespace' | |
28 sed -i 's, *$,,' a | |
29 hg commit -A -m 'trimmed trailing whitespace' | |
30 | |
31 #$ name: | |
32 exit 0 |