Mohan Cheema's Online Diary

Site Just to Keep Track of My Day to Day Work.

SVN Hook to stop commits without comments

| 1 Comment

As SVN admin we need to make sure any commits made to the repository should have comments associated it with. The reason to have comments during commits is simple to know what has been fixed or what new has been added to the repository. Here is the simple shell script I have written to stop the commits if comments has not been added.

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

SVNLOOK=/usr/bin/svnlook
LOGM=`$SVNLOOK log -t "$TXN" "$REPOS"`
AUTHOR=`$SVNLOOK author -t "$TXN" "$REPOS"`
LOGM1=`echo $LOGM | sed 's/ //g'`
LOGM2=`echo $LOGM | wc -w`

if [ "$LOGM1" == "" ]
then
echo -e "Comment is mandatory" 1>&2
exit 1
fi

if [ $LOGM2 -lt 5 ]
then
echo -e "Comment should be descriptive." 1>&2
exit 1
fi

exit 0

This script can be extend to make extra checks as well. I hope it will be helpful for someone out there.

You can also write SVN Hook to send email after commit

Share

Author: Mohan Cheema

I am a Commerce Graduate currently I am working as Senior Support Analyst (Linux Administrator) with medium sized MNC Company. If time permits I do freelance work like setting up the servers as per the requirement, do performance tuning and so on.

One Comment

  1. [MARKED AS SPAM BY ANTISPAM BEE | Server IP]
    it helped me!! Thx dude

Leave a Reply

Required fields are marked *.

*

* Copy this password:

* Type or paste password here:

2,883 Spam Comments Blocked so far by Spam Free Wordpress


CommentLuv badge

Notify me of followup comments via e-mail. You can also subscribe without commenting.