# !/bin/sh
# 
#  SVN_EDITOR script
# 
[ $#  -eq 1 ] || {
echo "usage: $0 file"
exit 1
} 

file=$1

ed=$VISUAL
[ -z $ed ] && ed=$EDITOR
[ -z $ed ] && ed=vi

cat <$file.$
Feature :
BugID :
Author :
Reviewer :
Description :
Changed List :
ENDTEMPLATE

cat $file >>$file.$
sum=`cksum $file.$`
if $ed $file.$; then
newsum=`cksum $file.$`
if [ "$newsum" != "$sum" ]; then
rm -f $file
mv $file.$ $file
else
rm -f $file.$
fi
else
echo "editor \"$ed\" failed"
exit 1
fi

将以上脚本保存为:~/.subversion/svn-log.template,并设置权限:

  chmod +x ~/.subversion/svn-log.template

并在.bashrc中设置:

export SVN_EDITOR=/home//.subversion/svn-log.template

然后执行

source ~/.bashrc

不重启使设置生效。

这样,每次checkin时,都会弹出如下模板:


# !/bin/sh
# 
#  SVN_EDITOR script
# 
[ $#  -eq 1 ] || {
echo "usage: $0 file"
exit 1
} 

file=$1

ed=$VISUAL
[ -z $ed ] && ed=$EDITOR
[ -z $ed ] && ed=vi

cat <$file.$
Feature :
BugID :
Author :
Reviewer :
Description :
Changed List :
ENDTEMPLATE

cat $file >>$file.$
sum=`cksum $file.$`
if $ed $file.$; then
newsum=`cksum $file.$`
if [ "$newsum" != "$sum" ]; then
rm -f $file
mv $file.$ $file
else
rm -f $file.$
fi
else
echo "editor \"$ed\" failed"
exit 1
fi