SVN 서버 설정에는 Commit 관련하여 hook 라는 여러가지 이벤트를 처리할 수 있는 방법이 있다.
Visual SVN 의 Repository 의 Property를 보면 Hooks 탭을 볼 수있는데 이 탭에서 여러가지 Event에 대한 설정을 할 수 있다.
Commit 관련하여 시작할 때와 파일을 올리고 Commit 하기 직전 그리고 Commit을 완료한 시점에 대한 hook를 설정할 수 있다.
start-commit
run before commit transaction begins, can be used to do special permission checking
pre-commit
run at the end of the transaction, but before commit. Often used to validate things such as a non zero length log message.
post-commit
runs after the transaction has been committed. Can be used for sending emails, or backing up repository.
- 출처 : Stack Overflow
pre-commit hook에 Windows 배치스크립트를 작성하여 검사할 수 있으며 이 스크립트가 0이 아닌 에러코드를 넘길 경우 Commit이 취소 된다.
아래 코드는 Stack Overflow에서 얻은 로그를 6자 이상 넣도록 하는 배치코드 이다.
setlocal enabledelayedexpansion set REPOS=%1 set TXN=%2 set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe" SET M= REM Concatenate all the lines in the commit message FOR /F "usebackq delims==" %%g IN (`%SVNLOOK% log -t %TXN% %REPOS%`) DO SET M=!M!%%g REM Make sure M is defined SET M=0%M% REM Here the 6 is the length we require IF NOT "%M:~6,1%"=="" goto NORMAL_EXIT :ERROR_TOO_SHORT echo "Commit note must be at least 6 letters" >&2 goto ERROR_EXIT :ERROR_EXIT exit /b 1 REM All checks passed, so allow the commit. :NORMAL_EXIT exit 0
No comments :
Post a Comment