Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

You could send the warnings via email using the mail command.

share|improve this answer
1  
Right, I'm aware of that, but I don't want to. If users get read an email about a file they've committed 15 minutes ago, they're unlikely to go fix it. If they get a message in the console, they might fix it. –  ℝaphink Sep 12 '11 at 15:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.