SVN post-commit hook sending a message back to client

梦想与她 提交于 2019-12-04 17:43:31

问题


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?


回答1:


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



回答2:


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.




回答3:


I had the same problem, with Apache and mod_svn. It turned out that the marshalling fails when the text being marshalled contained &, < or > characters. After substituting them with &amp;, &lt; and &gt; the text got through.



来源:https://stackoverflow.com/questions/8424670/svn-post-commit-hook-sending-a-message-back-to-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!