What are some common and/or useful pre-commit hooks for SVN?
What are some common and/or useful pre-commit hooks for SVN?
That a user has actually entered a comment on the commit message, and that it contains a particular issue number to track.
Checking for absolute paths in various text files (i.e. VRML, XML etc). Most of the checked-in code should never have absolute paths, yet some people and tools insist on producing hard-coded stuff.
I do a word count on submit messages. They need to be 5 words or more. This has led to some comedic insults against me...
I like using svn hooks to:
I check the filetype and make sure that certain banned types are not committed by accident (eg .obj, .pdb). Well, not since the first time someone checked in 2 gig of compiler-generated temporary files :(
for windows:
@echo off
svnlook log -t "%2" "%1" | c:\tools\grep -c "[a-zA-z0-9]" > nul
if %ERRORLEVEL% NEQ 1 goto DISALLOWED
echo Please enter a check-in comment 1>&2
exit 1
:DISALLOWED
svnlook changed -t %2 %1 > c:\temp\pre-commit.txt
findstr /G:"%1\hooks\ignore-matches.txt" c:\temp\pre-commit.txt > c:\temp\precommit-bad.txt
if %ERRORLEVEL% NEQ 0 exit /b 0
echo disallowed file extension >> c:\temp\precommit-bad.txt
type c:\temp\precommit-bad.txt 1>&2
exit 1
Insert a note into Mantis bugtracker with the changelist details based on the commit message having 'issue #' or the like via RegEx.