0

I have setup a svn server on my ubuntu.Now i want to use it from my windows machine using tortoise svn,but i want to put constraint that user should enter comment for add,checkout,update etc.I modified the the pre-commit.tmpl file in hooks folder as(got from internet)

REPOS="/home/svn/"
TXN="checkout"
SVNLOOK=/user/bin/svnlook
SVNLOOKOK=1
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || SVNLOOKOK=0
if [ $SVNLOOKOK = 0 ]; then
echo Empty log messages are not allowed. Please provide a proper log message. 1>&2
exit 1
fi

but this somehow doesnt seem to work?even the default script in that file dint work.I think problem with TXN or REPOS?

vishine
  • 63
  • 8
  • possible duplicate of [How can I prevent Subversion commits without comments?](http://stackoverflow.com/questions/1928023/how-can-i-prevent-subversion-commits-without-comments) – Ben Reser Jan 22 '14 at 07:35

2 Answers2

0

Pre-commit hook must be

  • Named just "pre-commit"
  • Be executable from the point of view of used OS (X bit and mask and correct format of bash|sh script)
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
0

There an a number problems with your script.

  • You probably need #!/bin/sh before the first line
  • REPOS and TXN should be being set from the args passed to the script on the command line, $1 and $2 respectively.
  • /user/bin/svnlook probably should be /usr/bin/svnlook
  • > should be > (your copy apparently copied the HTML encoded code)
  • 1>&2 should be 1>&2
  • You say you modified pre-commit.tmpl but did you rename it to just pre-commit?
  • Is the pre-commit file executable i.e. chmod a+x pre-commit?

For all practical purposes this is a duplicate of How can I prevent Subversion commits without comments?, which has several versions of this.

Community
  • 1
  • 1
Ben Reser
  • 5,695
  • 1
  • 21
  • 29
  • i have #!/bin/sh. i seem to have problem with values of TXN REPOS and svnlook. for TXN should i specify add,update,delete?if i want to run pre-commit on these events? – vishine Jan 23 '14 at 04:56
  • TXN should be set to the first argument like this `TXN="$1"` and REPOS should be set to the second argument like this `REPOS="$2"`. The `$1` and `$2` are literals and aren't intended for you to fill in, the values you need are passed to the script by Subversion. – Ben Reser Jan 23 '14 at 05:21
  • hey as i mentioned I am accessing repository from tortoise svn on windows,but svn server is on a linux machine.so how can i pass arguements? ps:thanks a lot for your help! – vishine Jan 23 '14 at 05:47
  • #!/bin/sh TXN=$1 REPOS=$2 SVNLOOK="/usr/bin/" $SVNLOOK log -t "$TXN" "$REPOS" | \ grep "[a-zA-Z0-9]" > /dev/null || exit 1 exit 0 is now the modified script,can you see what is causing the problem,and which is correct SVNLOOK="/usr/bin/" or SVNLOOK="/usr/bin/svnlook"? – vishine Jan 23 '14 at 05:49
  • SVNLOOK should be the path to whever the svnlook executable is on your system (`which svnlook` should be able to help you if you aren't sure, but realize there is no `PATH` environment variable set when the hook runs so you must provide a full path). You probably want to quote the `$1` and `$2` so `TXN="$1"` and `REPOS="$2"` – Ben Reser Jan 23 '14 at 06:12
  • thanks it worked..so if I don give any comment then it says precommit has blocked the transaction etc.I want to be more clear to user by saying something like "the transaction failed because your comment was empty".How can I display this – vishine Jan 23 '14 at 08:21