svn 强制注释


svn 强制注释

  • 将代码仓库根目录下,hooks文件夹中的pre-commit.tmpl文件重命名为pre-commit
  • pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
#$SVNLOOK log -t "$TXN" "$REPOS" | \
# grep "[a-zA-Z0-9]" > /dev/null || exit 1


# 定义个变量,注意这里不是单引号
LOGMSG=`$SVNLOOK log -t $TXN $REPOS | wc -m`

# 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


#这里为什么是48呢,一个汉字对应16个字符 必须填四个汉字
if [ "$LOGMSG" -lt 48 ]
then

echo "至少输入4个汉字的描述" >&2
exit 1
fi

# All checks passed, so allow the commit.
exit 0
  • 可执行权限 chmod +x pre-commit