Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there a way for me to simplify this pre-commit hook? It seems a bit much to me

message=`$SVNLOOK log -t "$TXN" "$REPOS"`

# Block any commits which don't reference a ticket
if echo $message | grep -q "re #"
elif echo $message | grep -q "references #"
elif echo $message | grep -q "refs #"
elif echo $message | grep -q "see #"
elif echo $message | grep -q "addresses #"
    echo "Your commit must reference a ticket to be accepted. For example, re #1234"
share|improve this question

2 Answers 2

up vote 1 down vote accepted

For this, you could use either gnur's variant or use a pattern file:

grep -q --file="matchpatterns.txt" 

which would contain every pattern you want to accept:

refs #
addresses #
ticket #
bug #

I like this more because this kind of list tends to become long very quick, making the inline pattern difficult to manage.

share|improve this answer
This is definitely the simplest and easiest to maintain! –  David Sep 12 '11 at 1:31

if echo $message | grep -q '\(re\|references\|refs\|see\|addresses\|\) #'

Should do the trick.

share|improve this answer
very nice, I should have known that regex has OR syntax! –  David Sep 12 '11 at 1:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.