首页 > 代码库 > svn 钩子脚本

svn 钩子脚本

#vim post-commit

#!/bin/bash

REPOS="$1" 
REV="$2" 
SVNLOOK="/usr/bin/svnlook"
echo "`date +%F`" >> /tmp/post.log
echo "REPOS=$1 REV=$2" >> /tmp/post.log
echo -e "\$@=$@#" >> /tmp/post.log
echo -e "`date +%F` end\n" >> /tmp/post.log
$SVNLOOK changed "$REPOS" >> /tmp/list.txt
project=`tail -n 1 /tmp/list.txt|awk ‘{print $2}‘|cut -d/ -f1-2`
echo "$project" >>/tmp/p
curl  "http://center.sky.com/project/file_interface.php?svnupdate=2&pname=$project&dir=&file=&revision="
#curl "http://center.sky.com/project/file_interface.php?pname=$project&dir=&ufile="

#vim pre-commit

SVNLOOK=/usr/bin/svnlook
REPOS="$1"
TXN="$2"
SCMLIST="superadmin,richard.wu" 
C_USER=`$SVNLOOK info  -t $TXN $REPOS|sed -n "1p"`;
if [ -z  `echo $SCMLIST|grep $C_USER` ]
then
        echo `$SVNLOOK changed -t $TXN $REPOS `  >  /dev/shm/commit_log 
        rm -rf /dev/shm/commit_log
        fi
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` 
if ! $SVNLOOK log -t "$TXN" "$REPOS" |grep -P -i "v\d\.\d+_?(\d*)";
then
        echo -e "please input product version:\n eg:v2.203_20130802\n eg:v0.007_20130907\n" 1>&2
        #echo -e "please input product version\n";
        exit 1;
fi
exit 0


本文出自 “秋风颂” 博客,请务必保留此出处http://qiufengsong.blog.51cto.com/7520243/1429897