Thursday, August 19, 2010

SVN Pre -commit script example. Deny commit if no comment or it is less than 10 caracters

This script will deny commit if there is no comment or comment is less than 10 characters.




########################################
REPOS="$1"
TXN="$2"
min=10






comment_entered=`svnlook log -t $TXN $REPOS`




comment_lenght=`echo $comment_entered  | wc -c | tr -d ' '`


if [ "$comment_lenght" -lt "$min" ]; then
 echo "" 1>&2
  echo "*** Your commit has been blocked because you did not give any log message or your log message was less than 10 caracters." 1>&2
  echo "Please write a log message describing the purpose of your changes and then try committing again." 1>&2
  exit 1
else
  exit 0
fi

##################################


You can copy paste above content in /svnroot/yourepo/hook/pre-commit . Good thing is that you don;t even need to make any changes in this script. 

Enjoy 

Amit ......


1 comment: