svnnotify commits for trunk only

SvnNotify commits

Emails about commits in SVN can be sent using svnnotify. Our system was set to send emails whenever there was any change to our repository.

svnnotify to email when commits are made to trunk

Our repository consisted of tags, trunk and branches. To make that happen, here’s what our <svn-repo>/hooks/post-commit file looked like:

REPOS="$1"
REV="$2"
HANDLER="HTML::ColorDiff"
TO="[email protected],[email protected]"
FROM="[email protected]"
REPLY="[email protected]"

/usr/bin/svnnotify -C -H $HANDLER\
        --repos-path "$REPOS" \
        --revision "$REV" \
        --to-regex-map $TO="^trunk/"  \
        --from $FROM \
        --reply-to $REPLY \
        --with-diff

Notice the –to-regex-map $TO=”^trunk/” line. An email is sent out when comments are made to trunk. No emails are sent when commits are made to branches and tags.

Multiple notifications can be sent in post-hook based on the repo to which commits have been made and such emails can be targeted to different email addresses.

Sources:

Also seeĀ 3 reasons to stay with SVN and not migrate to Git