Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN post-commit hook sending a message back to client

I'm writing a post-commit script in bash, and I'd like to pass messages back to the client who's making a commit. However

echo my message >&2

isn't making it back to the client. Is it even possible to send messages back with a post-commit hook?

like image 652
CamelBlues Avatar asked Dec 08 '11 00:12

CamelBlues


2 Answers

Hook will show STDERR only if it fails (and as you may now, hook doesn't display STDOUT). Thus, you have to return non-zero code from your script to pass "my message" to user (just add exit 1 after echo).

Take a look here:

If the post-commit hook returns a nonzero exit status, the commit will not be aborted since it has already completed. However, anything that the hook printed to stderr will be marshalled back to the client, making it easier to diagnose hook failures.

like image 143
pmod Avatar answered Oct 11 '22 17:10

pmod


Condering a post-commit hook does:

anything that the hook printed to stderr will be marshalled back to the client, making it easier to diagnose hook failures.

you can check if this isn't a simple quote issue:

echo "my message" >&2

You can see in those hook examples that any echo to >&2 includes quotes.

The bash chapter on redirection also includes examples with quotes.

However, as pmod details in his answer, that stderr message won't be visible unless the exit status of the script differs from 0, as illustrated in "subversion post-commit hook: print an error message that the user can see?"

#!/bin/bash
echo "test" >&2
exit 1
like image 26
VonC Avatar answered Oct 11 '22 16:10

VonC