将check.py 和 pre-commit.bat文件放到 svn 路径下的hooks文件夹下,其中check.py为格式 pre-commit.bat为windows环境下 执行脚本文件
校验正则格式为:
r'^项目:.+\n修改内容:.+\n修改时间:\d{4}-\d{2}-\d{2}\n修改人:.+$
check.py内容:
import re import sys message = sys.stdin.read() restr = r'^项目:.+\n修改内容:.+\n修改时间:\d{4}-\d{2}-\d{2}\n修改人:.+$' if re.match(restr, message) != None: exit(0) else: exit(1)
pre-commit.bat内容:
@echo off setlocal set REPOS=%1 set TXN=%2 set SVNLOOK="D:\Program Files\VisualSVN Server\bin" set PYTHON="D:\Program Files\Python" %SVNLOOK%\svnlook.exe log "%REPOS%" -t "%TXN%" | %PYTHON%\python.exe D:\Repositories\myRepositories\hooks\check.py > nul if %errorlevel% gtr 0 goto err exit 0 :err echo "Message does not conform" 1>&2 exit 1
如果提交message格式不满足py文件中的正则校验格式 就会限制提交并返回相关信息:
标签:SVN,.+,Windows,钩子,py,修改,set,exit,check From: https://www.cnblogs.com/skystrive/p/18455611