PRE-COMMIT HOOKREPOS="$1"
TXN="$2"
MAX_SIZE=31457280
MIN_LOG=10
# Make sure that the log message contains some text.
SVNLOOK=/data/csvn/bin/svnlook
# $SVNLOOK log -t "$TXN" "$REPOS" | \
# grep "[a-zA-Z0-9]" > /dev/null || exit 1
LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c)
if [ "$LOGMSG" -lt "$MIN_LOG" ]
then
echo -e "*** Your commit has been blocked because of blank comment log or your log message is less than 9 character ***" >&2
echo -e "*** Please write a log message and then try committing again. ***" >&2
echo -e "*** Thank You:Amit Anand***" >&2
exit 1
fi
files=$("$SVNLOOK" changed -t "$TXN" "$REPOS" | awk '{print $2}')
for f in $files
do
# check file size.
filesize=$($SVNLOOK cat -t "$TXN" "$REPOS" "$f" | wc -c)
if [ "$filesize" -gt "$MAX_SIZE" ]
then
echo -e "*** File $f is too large.***" >&2
echo -e "*** Thank You:CMTEAM***" >&2
exit 1
fi
done
# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
# commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
# All checks passed, so allow the commit.
exit 0
POST-COMMIT HOOK
REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"
# Only do actual work when the "svn:date" property is modified, which seems
# to be the last revision property modified by the svnsync process.
if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:date" ]; then
AUTHOR=`svnlook author $REPOS -r $REV`
DATE=`svnlook date $REPOS -r $REV`
LOG=`svnlook log $REPOS -r $REV`
echo "$REPOS@$REV: $LOG by $AUTHOR at $DATE"
fi
# mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf
# Example for synchronizing one repository from the post-commit hook
#SVNSYNC synchronize URL_TO_SLAVE_REPO --username=svnsync --password=svnsyncpassword
#svnsync initialize URL_TO_SLAVE_REPO URL_TO_MASTER_REPO --username=svnsync --password=svnsyncpassword
exit 0
PRE-REVPROP-CHANGE
#!/bin/sh
USER="$3"
if [ "$USER" = "svnsync" ]; then exit 0; fi
echo "Only the admin user may change revision properties as this is a read-only, mirror repository." >&2
exit 1
No comments:
Post a Comment