简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM