hgbook

diff en/examples/hook.simple @ 34:c0979ed1eabd

Get started on hook chapter.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun Jul 16 00:01:43 2006 -0700 (2006-07-16)
parents
children 5cee64874312
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/en/examples/hook.simple	Sun Jul 16 00:01:43 2006 -0700
     1.3 @@ -0,0 +1,34 @@
     1.4 +#$ name: init
     1.5 +
     1.6 +hg init hook-test
     1.7 +cd hook-test
     1.8 +echo '[hooks]' >> .hg/hgrc
     1.9 +echo 'commit = echo committed $HG_NODE' >> .hg/hgrc
    1.10 +cat .hg/hgrc
    1.11 +echo a > a
    1.12 +hg add a
    1.13 +hg commit -m 'testing commit hook'
    1.14 +
    1.15 +#$ name: ext
    1.16 +
    1.17 +echo 'commit.when = echo "date of commit:"; date' >> .hg/hgrc
    1.18 +echo a >> a
    1.19 +hg commit -m 'i have two hooks'
    1.20 +
    1.21 +#$ name:
    1.22 +
    1.23 +echo '#!/bin/sh' >> check_bug_id
    1.24 +echo '# check that a commit comment mentions a numeric bug id' >> check_bug_id
    1.25 +echo 'hg log -r $1 --template {desc} | grep -q "\<bug *[0-9]"' >> check_bug_id
    1.26 +chmod +x check_bug_id
    1.27 +
    1.28 +#$ name: pretxncommit
    1.29 +
    1.30 +cat check_bug_id
    1.31 +
    1.32 +echo 'pretxncommit.bug_id_required = ./check_bug_id $HG_NODE' >> .hg/hgrc
    1.33 +
    1.34 +echo a >> a
    1.35 +hg commit -m 'i am not mentioning a bug id'
    1.36 +
    1.37 +hg commit -m 'i refer you to bug 666'