user498274
user498274

Reputation: 11

pre-commit hook does not check pattern

I'm a newcomer in SVN and I'm trying to write a pre-commit hook that checks commit messages on the pattern ^ABC-[0-9]+|^CONFIG:+|^MERGE:. I am using this code:

if [ `/svn/bin/svnlook log -t "$TXN" "$REPOS" | egrep -v "^ABC-[0-9]+|^CONFIG:+|^MERGE:"` ];
then
    echo ""
        exit 1
fi;

But it does not work as I need and CLs with messages like "Test- test" can be commited anyway. What is the problem?

Thank you in advance!

Upvotes: 0

Views: 283

Answers (1)

Aimmal
Aimmal

Reputation: 21

The script below allows to commits only with the required pattern ^ABC-[0-9]+$|^CONFIG:|^MERGE:

REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
 grep -E "^ABC-[0-9]+$|^CONFIG:|^MERGE:" > /dev/null || exit 1

# Exit on all errors.
set -e


# All checks passed, so allow the commit.
exit 0

Upvotes: 2

Related Questions