Code review not only improves the quality, but also provides an excellent means of knowledge sharing and guidance.
Code review generally has two forms: Pre-commit-Review and post-commit-review.
Pre-commit-review refers to the Code submitted to the code library.BeforeCode review;
Post-commit-review refers to the Code submitted to the code library.AfterPerform code review.
Reviewboard is an open-source Web-based code review tool that supports subversion, CVS, git, and mercurial version control systems.
SVN can be integrated with reviewboard through the post-commit hook to implement post-commit-review.
The implementation principle is as follows:
The user triggers the post-commit hook script after the code is submitted to SVN.
Call the rbt post command of rbtools in SVN post-commit hook to connect to the reviewboard and automatically submit the code reviewrequest)
Note: rbtools is a python command line tool officially provided by reviewboard. It uses the python API to interact with the reviewboard.
The following problems occur during use:
The user must wait until the post-commit hook is executed to complete the submission.
In this wayThis results in a long wait time for the user to submit code., Affects the user experience
Therefore, the rbt post command called in post-commit should be executed in the background.
In this way, the post-commit command does not need to wait until the RBT post is executed. After the rbt post command is sent, the system directly returns
We know that in Linux, The & command can put the job to the background for execution.
However, the RBT command in the Post-commit hook is followed and does not work.
Search by Google
Finally, I found this article on stackoverflow and finally solved the problem.
In the past, we still needed to use 2> & 1 to convert all error output to standard output, so that both the error output and standard output are redirected to an out. File file.
2 indicates the error output, and 1 indicates the standard output.
RBT Post "$ ARGs" 2> & 1 &
I have to say that Google and stackoverflow are very powerful @!
Others:
For details about how to write SVN post-commit scripts, refer to the example of user contribution in reviewboard source code.
Rbt post command official guide
SVN integrates reviewboard to run post-commit hook in the background