需求一,svn提交時必須填寫log日志的需求,如何進行配置呢?請看下面。
需要在版本庫目錄下找到hooks文件夾,我的版本庫是dxoffice,所以是這個目錄,你要找自己的目錄
然后進入,創建一個pre-commit.bat文件,提交之前要做的一個hooks文件,編輯,將以下內容拷貝到文件中並進行保存。
@echo off :: :: Stops commits that have empty log messages. :: @echo off set svnlook="D:/Program Files/VisualSVN Server/bin/svnlook.exe" //此處是你的svnanzhu setlocal rem Subversion sends through the path to the repository and transaction id set REPOS=%1 set TXN=%2 rem check for an empty log message %svnlook% log %REPOS% -t %TXN% | findstr . > nul if %errorlevel% gtr 0 (goto err) else exit 0 :err echo. 1>&2 echo Your commit has been blocked because you didn't give any log message 1>&2 //此處是返回給客戶端的錯誤信息 echo Please write a log message describing the purpose of your changes and 1>&2 echo then try committing again. -- Thank you 1>&2 exit 1
如果您有最少提交多少字的需求,只需在%svnlook% log %REPOS% -t %TXN% | findstr . > nul這行代碼中找到findstr .在這里有一個 點表示最少輸入1個字符,如果是10個點代表最少輸入10個字符,以此類推。保存之后,不用重啟服務器就可以進行嘗試
需求二:提交svn后,需要同步web目錄
方法同上面差不多,創建post-commit.bat文件,然后將下面代碼拷貝到里面
@echo off SET REPOS=%1 SET REV=%2 SET DIR=%REPOS%/hooks SET PATH=%PATH%; SET WORKING_COPY=E:/svn_test //此處是你的項目路徑,此路徑必須是一個svn的路徑,這意味着你已經checkout出了源碼 svn update %WORKING_COPY% --username name --password password //輸入svn用戶名密碼
還有一個注意問題——Visual SVN Server的權限,否則可能會出現下列錯誤:
post-commit hook failed (exit code 1) with output:
svn: E155004: Working copy 'D:\www\Test' locked
svn: E200031: sqlite: attempt to write a readonly database
svn: E200031: sqlite: attempt to write a readonly database
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
原因是Visual SVN Server服務的執行權限不夠,不能對指定目錄做讀寫操作。解決辦法,修改Visual SVN Server
簡單操作 win+R 運行 services.msc 找到visual svn server 服務 右鍵屬性 先停止服務之后,再設置登陸,設置桌面交互或者管理員權限
注:http://blog.csdn.net/ght521/article/details/52355778