1

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!

1 Answers1

0
  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
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • I think filesize will work. But I have never tried that command before. If you can please give me the correct syntax that would be very helpful. I am trying below command but it is giving error. svnlook filesize %REPOS% -t %TXN% | Set size=%%~ZA – user4585570 Feb 23 '15 at 16:07
  • @user4585570 - I can recall `%%~ZA` meaning, but anyway you have to define **file from transaction** `svnlook filesize %REPOS% -t %TXN% file/in/transaction` and repeat this command for every file. filesize will output to stdout 10-digit number - size *in bytes* – Lazy Badger Feb 26 '15 at 16:25