How to send stdout to the user when running SVN pre-commit hook

一个人想着一个人 提交于 2019-12-05 06:08:49

Subversion hooks eat their STDOUT. Once the script is run, there is no STDOUT. You can't even have the pre-commit script send STDOUT to another process.

However inside the pre-commit hook, STDOUT still exists and can still be redirected. For example, my hook consists of a shell script consisting of several lines of Unix command line utilities. Each command line utility has a STDIN and a STDOUT, and I can pipe from one to the other. But, once that hook script finishes executing, there is no STDOUT.

The other thing is that there is no way to communicate STDOUT via the hook paradigm. Subversion doesn't provide any sort of communications link. There is a link for STDERR, but only if the hook itself fails. This being a pre-commit hook, I doubt you purposely want to fail this hook just to give the user the report.

What you can do is use other methods of notification. Some people suggested email. You could run a post-commit script to generate the report and email that report based upon the user's email address. I would not do this as a pre-commit trigger because you don't want the transaction to fail because the report didn't work.

Some people suggested that you can map the user who did the commit with an email address and email the user. I would not do this because the users will simply ignore the email. They already get dozens if not hundreds of emails from various processes alerting them to this or that.

What I would recommend is to use a product like Hudson to do continuous builds, and have this report generated by Hudson and posted on the build page Hudson generates. This way, a developer can go back and examine the report. In fact, Hudson already has various plugins that do error checking and produces all sorts of nice reports and graphs (usually working with findbugs or other projects like that).

One of the more interesting plugins is a game that awards points for successful builds, fixing bugs and warnings, etc. It presents a leader board, so developers can compare their score to other developers. I never used it, but some people on the Hudson user group say that the developers get very competitive over their scores.

You must map the username to an email address somehow. Then you can collect the output in a file and mail it to the committer.

In my case, I wrote a simple C# Windows form application to display the progress of the hook.

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