hgbook

annotate ja/examples/hook.ws @ 862:ad6d3f5245e7

Link back to the original English version of the book.
author gpiancastelli
date Fri Aug 28 12:21:45 2009 +0200 (2009-08-28)
parents
children
rev   line source
foozy@708 1 #!/bin/bash
foozy@708 2
foozy@708 3 hg init a
foozy@708 4 cd a
foozy@708 5 echo '[hooks]' > .hg/hgrc
foozy@708 6 echo "pretxncommit.whitespace = hg export tip | (! egrep -q '^\\+.*[ \\t]$')" >> .hg/hgrc
foozy@708 7
foozy@708 8 #$ name: simple
foozy@708 9
foozy@708 10 cat .hg/hgrc
foozy@708 11 echo 'a ' > a
foozy@708 12 hg commit -A -m 'test with trailing whitespace'
foozy@708 13 echo 'a' > a
foozy@708 14 hg commit -A -m 'drop trailing whitespace and try again'
foozy@708 15
foozy@708 16 #$ name:
foozy@708 17
foozy@708 18 echo '[hooks]' > .hg/hgrc
foozy@708 19 echo "pretxncommit.whitespace = .hg/check_whitespace.py" >> .hg/hgrc
foozy@708 20 cp $EXAMPLE_DIR/data/check_whitespace.py .hg
foozy@708 21
foozy@708 22 #$ name: better
foozy@708 23
foozy@708 24 cat .hg/hgrc
foozy@708 25 echo 'a ' >> a
foozy@708 26 hg commit -A -m 'add new line with trailing whitespace'
foozy@708 27 sed -i 's, *$,,' a
foozy@708 28 hg commit -A -m 'trimmed trailing whitespace'
foozy@708 29
foozy@708 30 #$ name:
foozy@708 31 exit 0