1
votes

I have an existing pre-commit hook working fine however when I use start-commit hook I get "Commit blocked by start-commit hook (exit code 255) with no output.) The start-commit looks like this...


#!/bin/sh
REPOS="$1"
USER="$2"
grep $USER /var/svn/repos/testrepo/hooks/owasp_users.txt
GREP_STATUS=$?
if [ $GREP_STATUS -ne 0 ]
then
    echo  $GREP_STATUS 1>&2
    echo  $REPOS-PATH 1>&2
    echo  $USER 1>&2
    exit 1
fi
exit 0

The working pre-commit looks like this...


#!/bin/sh

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

SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" > /dev/null

GREP_STATUS=$?
if [ $GREP_STATUS -ne 0 ]
then
    echo "Your commit has been blocked because you didn't add a log message." 1>&2
    echo "Please write a log message describing the purpose of your changes and" 1>&2
    echo "then try committing again. -- Thank you" 1>&2
    exit 1
fi
exit 0

The file has execute permissions and no matter the code in start-commit I get the 255 error. I can get past with just the first line #!/bin/sh but add even a simple line return and the 255 error returns.

1

1 Answers

0
votes

I missed converting DOS line endings while editing the hooks, a quick dos2unix fixed the issue. It acts very weird due to the different ways bash and hooks works with CRLF added to the fact that you can't see stdout this wasted hours of my day.