tags:

views:

185

answers:

4

I currently block any commit to SVN that does not contain a comment using pre-commit hooks.

Now I wish to extend this so that the Commit comment must have the line

"Reviewed by: name"

Currently the pre commit hook file looks like

:: SET REPOS=%1

:: Transform forward-slashes to back-slashes for Windows
:: SET REPOS=%REPOS:/=^\%

"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO CHECKSUOFILES
echo "Commit Comments are Required" >&2
exit 1

Has anyone implemented something similar?

I am currently using SVN 1.6.0

+1  A: 

I took a fairly primitive route to answer my own question. I altered the pre commit hook to look for the text "Reviewed by: " or else it will block the commit

There are problems with this

  • You can circumvent it just by entering the Reviewed By: and then not a name
  • We are asking developers to enter Reviewed by: No-one for un-reviewed commits

However it will allow us to parse the SVN logs to see what has/hasn't been reviewed and by whom.

Dean
+5  A: 

This seems like bad practice to me - forcing something to be reviewed will inhibit frequent checkins, which is one of the things you want to encourage. In general, I am a bit dismayed by the apparent trend to use version control software as some sort of workflow management system - that is not what it is intended for at all!

anon
+1  A: 

You basically already have an example right there. Just add something like:

set reviewed=no
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr "reviewed by" && set reviewed=yes
if "%reviewed%"=="no" GOTO NOTREVIEWED

However.

Reviewing a change is easiest when the change has already been committed. Also, as already mentioned by Neil, you don't want to discourage regular bite size commits. Reviewing huge blobs of change doesn't work well.

If you really want to make sure that every change is reviewed, you should use the concept of feature branches. Make a branch for each change, and allow frequent small commits without reviews there. When the change is ready, the reviewer can examine it commit by commit and merge the changes into trunk.

Wim Coenen
A: 

You might want to look into using something like Git ( http://git-scm.com/ ) instead of SVN. With Git, you can have a "blessed" version of the project that can only be written to by your reviewers. The individuals all work with the code on their local machines and can push their changes up to a "review" instance of the project. The reviewers can see the changes in the "review" instance and push individual changes up to the "blessed" version.

Git can also convert your existing SVN projects directly.

Shane
This is not really an argument for switching to git. You can also "bless" a branch in SVN.
Wim Coenen