2

I have implemented the below code in my hook script file abc-pre-commit.bat to disallow commit if files contain the string cod_bank

SETLOCAL
SET PATH=C:\Windows;C:\Windows\system32;D:\SCC\SVN146\ bin;C:\Program Files\VisualSVN Server\bin;
set SVNLOOK = "C:\ProgramFiles\VisualSVNServer\bin\svnlook.exe"

set REPOS=%1
set TXN=%2

%SVNLOOK% diff %REPOS% -t %TXN% | findstr /I /M /L cod_bank > nul


if %errorlevel% gtr 0 (
exit 0
) else (
echo Your commit has been blocked because it contains the keyword cod_bank. 1>&2
exit 1
)

My file does contains the string cod_bank

OUTPUT: in commit window it shows

commit blocked by pre-commit-hook

It does not displays the echo msg also how can I store the o/p of the svnlook diff command. I tried but was not successful.

Emil Sit
  • 22,894
  • 7
  • 53
  • 75

1 Answers1

2

In Linux It works like this:

#!/bin/sh
REPOS="$1"
TXN="$2"


SVNLOOK=/usr/bin/svnlook
$SVNLOOK diff "$REPOS" -t "$TXN" | \
[[ grep "^+cod_bank">/dev/null exit 0 ]]  ||
echo "Your commit has been blocked because it contains the keyword cod_bank"  >&2
exit 1
Wenwen
  • 51
  • 2