Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLibHow-TosSubversion

Example: Prevent that "Connected = True" is written in any *.dfm file.

Following file needs to be created: C:\Repositories\...\Hooks\pre-commit.bat

@echo off

SET PATH=%PATH%;C:\Program Files\VisualSVN Server\bin\

setlocal enableextensions EnableDelayedExpansion

for /f "tokens=1,* usebackq" %%i in (`svnlook changed -t %2 %1`) do (
        for %%A in ("A", "U") do if "%%i"==%%A (
                set "changetype=%%i"
                set "filename=%%j"
                if /I "!filename:~-3!"=="dfm" (
                        svnlook cat -t %2 %1 "!filename!" | findstr /C:"ConnectionString" > NUL
                        if not errorlevel 1 (
                                echo -------------------------------------------- >&2
                                echo PRE COMMIT CHECK FAILED! >&2
                                echo You forgot to remove a ConnectionString attribute! >&2
                                echo !filename! >&2
                                echo -------------------------------------------- >&2
                                exit 1
                        )

                )
        )
)
Daniel Marschall
ViaThinkSoft Co-Founder