0

I am using CollabNet Subversion in Windows, I been searching around on how can I force user to put in their comment before committing their changes into SVN. The search result are more focus in Linux enviroment, and very less resource in Windows environment. So lucky that I found this link which is targeted on Windows.

Unfortunately, with the code provided, I still couldn't get it work in TortoiseSVN and EclipseSVN. According to the comment provided, the pre-commit.tmpl should be rename to pre-commit.bat, but it still not working.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
huahsin68
  • 6,819
  • 20
  • 79
  • 113

2 Answers2

3

Here's a pre-commit hook script for Subversion running on Linux:

https://injustfiveminutes.wordpress.com/2012/11/15/how-to-force-comments-on-subversion-commit-with-perl-hook-script/

lupas
  • 31
  • 1
3

Did you put that script into \hooks folder? If yes I suspect that script mentioned lacks environment setup (since hooks are executed in a clean environment). From SVN book:

For security reasons, the Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH (or %PATH%, under Windows). Because of this, many administrators are baffled when their hook program runs fine by hand, but doesn't work when run by Subversion. Be sure to explicitly set any necessary environment variables in your hook program and/or use absolute paths to programs.

Try running with just echoes at first to be sure it is invoked by server at all:

@echo off
setlocal

echo Commit stopped 1>&2
exit 1

If it's working, then try adding this on the top of that batch:

rem Add path to Subversion executable
set path=%path%;c:\Program Files\Subversion\bin

BTW, I also found a related article here (contains also pre-commit hook example).

Update

You may also try solution for the same problem here: SVN Pre Commit Hooks

Update2

I think you are messing up client side hooks with server side ones. The first is invoked by SVN client, so parameters passed and how results are interpreted are totally client specific. I suppose the TortoiseSVN hooks are not intended to reject commits (i.e. errorlevel is not checked) but can be used for integration with other systems. See also example here. To really reject commits - you need to add these hooks on SVN server.

Community
  • 1
  • 1
pmod
  • 10,450
  • 1
  • 37
  • 50
  • Yes, I have the file inside hooks folder. I have your code place in pre-commit.bat file, but why I still able to commit the file? May I know is it the file that Subversion will automatically trigger? – huahsin68 Dec 29 '11 at 08:54
  • After placing that in pre-commit.bat - did you see "Commit stopped" message? – pmod Dec 29 '11 at 09:01
  • yes. I saw the Commit stopped. And according to the link you have provided, I have set the path that point to subversion and also the grep.exe. With this code "svnlook.exe log -t "%2" "%1" | grep.exe "[a-zA-Z0-9]" nul || exit 1" in the script as well. I still can proceed to checkin my code even I didn't comment anything. – huahsin68 Dec 30 '11 at 01:31
  • I think the very first place is to get the TortoisesSVN or EclipseSVN to trigger the pre-commit.bat file. Because I still can commit my changes even though the pre-commit.bat script only contain the code "exit 1". – huahsin68 Dec 30 '11 at 01:48
  • you have pointing out the most valuable hints on this question. Thanks a lot. – huahsin68 Jan 03 '12 at 14:23