Svn – Throw a warning in pre-commit hook

svn

I would like to throw a warning in a pre-commit hook but without aborting the commit. However, it seems svn bufferizes the output and only displays it if the check aborts.

Is it possible to output warnings without aborting?

Best Answer

Warnings can actually be achieved in post-commit hooks by making them fail (with $? != 0, just as with pre-commit hooks).

So in my case, I made the command I'm using return 1 for errors and 2 for warnings, and I call it in both pre- and post-commit hooks.

In the pre-commit hook, I have:

/usr/bin/augeas-validator $(svnlook changed -t "$TXN" "$REPOS" | awk '/^[^D].*$/ {print $2}')
if [ $? = 1 ]; then
   exit 1
fi

while in the post-commit hook, I have:

/usr/bin/augeas-validator $(svnlook changed -r "$REV" "$REPOS" | awk '/^[^D].*$/ {print $2}') || exit 1

Thus, errors prevent the commit while warnings only make the post-commit hook error out, which doesn't prevent the commit but still warns the user with the content of STDERR.

Related Topic