windowsbatch-filesvnpre-commitsvnlook

svnlook cat :: batch script to limit the commit size to 10MB


I am working to create a pre-commit hook script which will restrict users (developer) to 10MB commit. So this will help to reduce the repository size. Below is the script which needs to be run on windows server using subversion 1.8.

@echo off  
setlocal 

@CD C:\Progra~2\VISUAL~1\bin
Set REPOS=%1
Set TXN=%2
Set MAX_SIZE=10485760
svnlook cat %REPOS% -t %TXN% | Set size=%%~ZA
If %%size%% GEQ %%MAX_SIZE%% (goto err) else exit 0
:err  echo. 1>&2  
echo Your commit has been blocked because your commit size is greater than    10MB 1>&2  
echo Please reduce your commit file size to below 10MB and try again 1>&2
echo Thanks 1>&2
exit 1

Error getting is Commit failed (details follow): Commit blocked by pre-commit hook (exit code 1) with output: svnlook: E205001: Try 'svnlook help' for more info svnlook: E205001: Missing repository path argument

If anyone can help on this script. Thanks!


Solution

    1. With svnlook cat you can output only individual files
    2. In order to get size of any file in transaction, you have to use another subcommand: filesize
    3. filesize works on per-file basis, you must to pipe into xargs (or it's Win-replacement) list of files in transaction with changed subcommand