I want to create a pre-commit hook in SVN (i.e. .bat file for Windows) that checks for empty log messages. Moreover, I want to target this check only for a particular folder in SVN.
Can anybody help regarding the same?
Regards, Ruhee Jaiswal
I want to create a pre-commit hook in SVN (i.e. .bat file for Windows) that checks for empty log messages. Moreover, I want to target this check only for a particular folder in SVN.
Can anybody help regarding the same?
Regards, Ruhee Jaiswal
I would recommend using a svn property for this if you're on Windows and using TortoiseSVN.
tsvn:logminsize sets the minimum length of a log message for a commit. If you enter a shorter message than specified here, the commit is disabled. This feature is very useful for reminding you to supply a proper descriptive message for every commit. If this property is not set, or the value is zero, empty log messages are allowed.
Also make sure to check out the other features like bug tracker integration.
If you'd really like to do this on the server side using a hook you can try this, in which case your question is a duplicate :)
In addition to this answer Windows Pre-commit hook for comment length Subversion you can use svnlook dir-changed
to check for specific directories of the current commit.
So you could add something like
svnlook dir-changed %REPOS% -t %TXN% | findstr your_path > nul
if %errorlevel% equ 0 exit 0
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0
If you're fine with TortoiseSVN, you could enter a client-side hook there.
TortoiseSVN passes the following parameters to the pre-commit hook:
where the interesting one is
PATH
:So, when your hook is called (could be in any language btw), do the following steps:
MESSAGEFILE
. If there's a comment inside, everything is fine, return successful from the script (I don't remember whether success is indicated by 0 or !0, just give it a try)MESSAGEFILE
is empty, browse through the filePATH
and see if there are affected elements in that. If so, return an error; otherwise return success.