當前位置:首頁 » 編程軟體 » svn提交腳本

svn提交腳本

發布時間: 2023-02-06 18:49:10

『壹』 如何設置SVN提交時強制添加註釋

rem SVN強制寫注釋的hooks腳本(Windows)
rem 文件名是: pre-commit.bat,放到repository/hooks目錄下setlocalset SVN_BINDIR="C:\Program Files\CollabNet\Subversion Server"
set REPOS=%1set TXN=%2rem check that logmessage contains at least 10 characters
%SVN_BINDIR%\svnlook log "%REPOS%" -t "%TXN%" | findstr "......" > nul
if %errorlevel% gtr 0 goto errexit 0:errecho 提交時必須填寫注釋(Message)! 1>&21.用SVN幾個問題的解決

『貳』 windows 2008 64bit設置svn強制提交注釋

將以下代碼復制到一個txt文檔中,放到Repositories\XXX\hooks目錄下(其中XXX為庫名),並將這個txt文檔改名為pre-commit.bat ,就可以對這個XXX庫進行限制,此hook限制字數為10個字。

@echo
rem SVN強制寫注釋的hooks腳本(Windows)
rem 文件名是: pre-commit.bat,放到repository/hooks目錄下
setlocal
set SVN_BINDIR="D:\Program Files\VisualSVN Server\bin"
set REPOS=%1
set TXN=%2

rem 檢查是否提交日誌
%SVN_BINDIR%\svnlook log -t "%TXN%" "%REPOS%" | findstr "..............." > nul
if %errorlevel% gtr 0 goto nolog

:nolog
echo Log (Message) is an important information, tracking document must be input, not the input meaningless characters, length shall not be less than 15 characters! >&2
exit 1

『叄』 SVN到Git的一鍵遷移腳本(保留所有分支、Tag及提交記錄)

注意:
1、由於用到grep、sort、awk,因此在Windows環境中需要在bash中運行,如果沒有的話先安裝Git即可;
2、需要安裝svn的命令號工具,如果沒有的話需要安裝下:

在SVN中,每一個人提交時都需要在系統中有一個用戶,它會被記錄在提交信息內。如果想要將SVN用戶映射到一個更好的Git作者數據中,你需要一個SVN用戶到Git用戶的映射。參考《 一鍵獲取所有SVN提交作者用戶名的列表 》獲取所有SVN提交作者,參考下面的格式建立authors.txt文件:

保存到與authors.txt同一目錄,並且修改裡面的SVN地址。

在終端下(windows在bash下),切換到 svn2git.sh 所在的目錄,執行: sh ./svn2git.sh 。 執行需要比較久的時間,需要耐心等待 ^o^ 。轉換完成後,轉換結果在當前目錄下的svn2git。

參考:
http://www.meilongkui.com/archives/1965

『肆』 如何通過svn鉤子腳本記錄提交人,提交庫,提交文件,提交時間

其實原理很簡單,就是利用svn的鉤子:post-commit,在提交過後想做什麼在這個腳本里就寫什麼。
假設我們的SVN目錄是:/home/svn
我們需要同步的web目錄是:/home/www/web(前提,這個web目錄也是從svn裡面檢出的)

『伍』 svn伺服器的代碼可以同步到伺服器嗎

開發過程中,需要經常將SVN伺服器上的代碼同步到測試伺服器上,一般做法,需要人工手工更新,這樣很浪費工夫。下面的腳本為svnserver的鉤子程序,放在svn伺服器上,只要代碼更新,就會自動提交的測試伺服器上。

使用條件:

1、SVN主機是WIN系統,如果要在linux的SVN主機上用,需要修改下面的代碼為sh腳本,道理類似,代碼不同。有需要的自行更改吧。

2、SVN主機上需要安裝完整版的PUTTY安裝包,而不是一個EXE.

3、測試伺服器可以用putty登錄

@echooff

rem本腳本實現將SVN伺服器A(win環境)上提交的代碼,自動上傳(通過pscp)到測試環境的伺服器B(linux)上,如果SVN在LINUX環境下,根據本代碼自行調整。


remsvn伺服器上版本庫地址

setreposLoc=%1

setREV=%2


rem----------------------------------------------------------------------配置開始

remsvn伺服器上putty的路徑

setputtyPath="D:ProgramFiles(x86)PuTTY"


rem測試環境putty登錄的用戶名

setusername=root


rem測試環境putty登錄的密碼

setpassword=password


rem測試環境IP

sethost=10.1.1.1


rem測試環境代碼根地址

setremoteRootPath=/var/www/htdocs/test


rem----------------------------------------------------------------------配置結束


cd/d%puttyPath%


rem遍歷提交了的代碼

for/f"tokens=2delims="%%iin('svnlookchanged%reposLoc%')do(


set"var=%%i"


svnlookcat!reposLoc!!var!>temp.txt


rem替掉路徑中的trunk

setnewPath=!var:trunk=!


rem通過pscp提交到測試伺服器

echoy|pscp-l!username!-pw!password!temp.txt!host!:!remoteRootPath!!newPath!

)

使用方法:

將上面的代碼中配置區的變數修改,並將內容保存成bat文件,命名為post-commit.bat,放在SVN伺服器上版本庫的hooks目錄下。提交代碼試試看吧。經測試可行。

當然,這個腳本可以再做的牛比點兒,可以針對某個用戶的提交做更新,也可以分析SVN提交時的日誌,只有當日誌中有特定的字元時更新。

另外,由於上面的腳本,只更新當前的提交,所以假設只針對某個用戶的提交做更新時,不能只更新當前提交,這樣其它用戶的提交就落掉了,需要更新整個工程。


『陸』 什麼是svn的鉤子腳本

1. SVN(Subversion)簡介
SVN是類似於VSS 和 CVS 的版本管理軟體,是CVS的作者另起爐灶開發的,繼承了CVS的優點,避免了CVS的一些缺點.
客戶端軟體TortoiseSVN與資源管理器結合,使用非常方便.
2.安裝文件及說明文檔所在目錄:
客戶端安裝文件:
http://203.187.176.183/TortoiseSVN-1.1.7-UNICODE_svn-1.1.4.msi
中文語言包:
http://203.187.176.183/LanguagePack_1.1.7_zh_CN.exe
3.簡要說明
由於客戶端軟體TortoiseSVN與資源管理器結合使用,所以安裝後要reboot
中文語言包使用方法: 桌面或資源管理器的任何地方右鍵,
4 基本操作
Svn伺服器地址203.187.176.183
每人自己一個私有目錄,URL分別是
svn//203.187.176.183/yhb
svn//203.187.176.183/zwb
svn//203.187.176.183/ldh
svn//203.187.176.183/pb
svn//203.187.176.183/pub
你的賬號密碼通過手機簡訊發給你.
輸入你自己的URL ,比如:svn//203.187.176.183/zwb
常用操作:將一個已有的工程加入SVN
例如:有目錄 e:\project1 ,導入 SVN
導入到你的URL下面的某個子目錄下:
比如:svn//203.187.176.183/zwb/project1
然後用"SVN 取出"功能從剛導入的或別人導入的工程獲得一個working .
Important
You can only check out into an empty directory. If you want to check out a previously imported sourcetree, Subversion will throw an error messge. You will have to check out into a different directory or delete the existing sourcetree first
要想check out (取出)到剛才進行導入的目錄,必須先刪除原目錄中的文件,或新建個目錄
取出 操作成功後,目錄會有個綠色的勾, 並增加了一個目錄 .svn
-------修改過的文件會有紅色標識,新增加的文件沒有任何標識------
―――使用SVN提交 將改動上傳到SVN伺服器 ――――――――――――――
改動過的文件和新增加文件會在列表中,要都選中.

『柒』 如何使用命令調用TortoiseSVN的提交功能

TortoiseSVN是一個GUI客戶端,這個自動化指導為你展示了讓TortoiseSVN對話框顯示並收集客戶輸入,如果你希望編寫不需要輸入的腳本,你應該使用官方的Subversion命令行客戶端。
TortoiseSVN的GUI程序叫做TortoiseProc.exe。所有的命令通過參數/command:asdf指定,其中asdf是必須的命令名(命令名詳見」表 1. 有效命令及選項列表「)。大多數此類命令至少需要一個路徑參數,使用/path:"some\path"指定。在下面的命令表格中,命令引用的是/command:asdf參數,餘下的代表了/path:"some\path"參數。
因為一些命令需要一個目標路徑的列表(例如提交一些特定的文件),/path參數可以接收多個路徑,使用*分割。
TortoiseSVN 使用臨時文件在 shell 擴展和主程序之間傳遞多個參數。從 TortoiseSVN 1.5.0 開始,廢棄/notempfile參數,不再需要增加此參數。
The progress dialog which is used for commits, updates and many more commands usually stays open after the command has finished until the user presses theOK button. This can be changed by checking the corresponding option in the settings dialog. But using that setting will close the progress dialog, no matter if you start the command from your batch file or from the TortoiseSVN context menu.
To specify a different location of the configuration file, use the parameter /configdir:"path\to\config\directory". This will override the default path, including any registry setting.
如果想在進度對話框執行完畢後自動關閉,而又不必設置永久性的參數,可以傳遞/closeonend參數。
/closeonend:0 不自動關閉對話框
/closeonend:1 如果沒發生錯誤則自動關閉對話框
/closeonend:2 如果沒發生錯誤和沖突則自動關閉對話框
/closeonend:3如果沒有錯誤、沖突和合並,會自動關閉
下面的列表列出了所有可以使用TortoiseProc.exe訪問的命令,就像上面的描述,必須使用/command:asdf的形式,在列表中,因為節省空間的關系省略了/command的前綴。

表 1. 有效命令及選項列表

命令
描述

:about 顯示關於對話框。如果沒有給命令也會顯示。
:log 打開日誌對話框,/path 指定了顯示日誌的文件或目錄,另外還有三個選項可以設置: /startrev:xxx、/endrev:xxx和/strict
:checkout 打開檢出對話框,/path指定了目標路徑,而/url制定了檢出的URL。
:import 打開導入對話框,/path 指定了數據導入路徑。
:update 將工作副本的/path更新到HEAD,如果給定參數/rev,就會彈出一個對話框詢問用戶需要更新到哪個修訂版本。為了防止指定修訂版本號/rev:1234的對話框,需要選項/nonrecursive和/ignoreexternals。
:commit 打開提交對話框,/path 指定了目標路徑或需要提交的文件列表,你也可以使用參數 /logmsg 給提交窗口傳遞預定義的日誌信息,或者你不希望將日誌傳遞給命令行,你也可以使用/logmsgfile:path,path 指向了保存日誌信息的文件。為了預先填入bug的ID(如果你設置了集成bug追蹤屬性),你可以使用/bugid:"the bug id here"完成這個任務。
:add 將/path的文件添加到版本控制 。
:revert 恢復工作副本的本地修改,/path說明恢復哪些條目。
:cleanup 清理中斷和終止的操作,將工作副本的/path解鎖。
:resolve 將/path指定文件的沖突標示為解決,如果給定/noquestion,解決不會向用戶確認操作。
:repocreate 在/path創建一個版本庫。
:switch 打開選項對話框。/path 指定目標目錄。
:export 將/path的工作副本導出到另一個目錄,如果/path指向另一個未版本控制目錄,對話框會詢問要導出到/path的URL。
:merge Opens the merge dialog. The /path specifies the target directory. For merging a revision range, the following options are available: /fromurl:URL, /revrange:string. For merging two repository trees, the following options are available: /fromurl:URL, /tourl:URL, /fromrev:xxx and /torev:xxx. These pre-fill the relevant fields in the merge dialog.
:mergeall Opens the merge all dialog. The /path specifies the target directory.
: Brings up the branch/tag dialog. The /path is the working to branch/tag from. And the /url is the target URL. You can also specify the /logmsg switch to pass a predefined log message to the branch/tag dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message.
:settings 打開設置對話框。
:remove 從版本控制里移除/path中的文件。
:rename 重命名/path的文件,會在對話框中詢問新文件,為了防止一個步驟中詢問相似文件,傳遞/noquestion。
:diff Starts the external diff program specified in the TortoiseSVN settings. The /path specifies the first file. If the option /path2 is set, then the diff program is started with those two files. If /path2 is omitted, then the diff is done between the file in /path and its BASE. To explicitly set the revision numbers use /startrev:xxx and /endrev:xxx. If/blame is set and /path2 is not set, then the diff is done by first blaming the files with the given revisions.
:showcompare
Depending on the URLs and revisions to compare, this either shows a unified diff (if the option unified is set), a dialog with a list of files that have changed or if the URLs point to files starts the diff viewer for those two files.
The options url1, url2, revision1 and revision2 must be specified. The options pegrevision, ignoreancestry, blame and unified are optional.

:conflicteditor Starts the conflict editor specified in the TortoiseSVN settings with the correct files for the conflicted file in /path.
:relocate 打開重定位對話框,/path指定了重定位的工作副本路徑。
:help 打開幫助文件
:repostatus 打開為修改檢出對話框,/path 指定了工作副本目錄。
:repobrowser Starts the repository browser dialog, pointing to the URL of the working given in /path or /path points directly to an URL. An additional option /rev:xxx can be used to specify the revision which the repository browser should show. If the /rev:xxx is omitted, it defaults to HEAD. If /path points to an URL, the /projectpropertiespath:path/to/wcspecifies the path from where to read and use the project properties.
:ignore 將/path中的對象加入到忽略列表,也就是將這些文件添加到 svn:ignore 屬性。
:blame
為 /path 選項指定的文件打開追溯對話框。
如果設置了 /startrev 和 /endrev 選項,不會顯示詢問追溯范圍對話框,直接使用這些選項中的版本號。
如果設置了 /line:nnn 選項,TortoiseBlame 會顯示指定行數。
也支持 /ignoreeol,/ignorespaces 和 /ignoreallspaces 選項。

:cat 將/path指定的工作副本或URL的文件保存到/savepath:path,修訂版本號在/revision:xxx,這樣可以得到特定修訂版本的文件。
:createpatch 創建/path下的補丁文件。
:revisiongraph 顯示/path目錄下的版本變化圖。
:lock Locks a file or all files in a directory given in /path. The 'lock' dialog is shown so the user can enter a comment for the lock.
:unlock Unlocks a file or all files in a directory given in /path.
:rebuildiconcache Rebuilds the windows icon cache. Only use this in case the windows icons are corrupted. A side effect of this (which can't be avoided) is that the icons on the desktop get rearranged. To suppress the message box, pass /noquestion.
:properties 顯示 /path 給出的路徑之屬性對話框。

Examples (which should be entered on one line):
TortoiseProc.exe /command:commit
/path:"c:\svn_wc\file1.txt*c:\svn_wc\file2.txt"
/logmsg:"test log message" /closeonend:0

TortoiseProc.exe /command:update /path:"c:\svn_wc\" /closeonend:0

TortoiseProc.exe /command:log /path:"c:\svn_wc\file1.txt"
/startrev:50 /endrev:60 /closeonend:0

『捌』 svn配置鉤子更新網站目錄 每次提交 程序會卡在正在發送文件 有人說是 腳本有問題 手動執行腳本沒有問題

把報錯信息發上來看看。
如果報錯說被某個鉤子阻止,就檢查那個鉤子是否有問題。如果那個鉤子手動執行沒問題,最常見的原因的就是path路徑問題,一般把鉤子里的命令行都改成絕對路徑就OK了。

『玖』 SVN的POST-COMMIT鉤子怎麼用

利用SVN的POST-COMMIT鉤子自動部署代碼

我們在開發的過程將代碼提交到SVN後使用SVN的hook,通過post-commit腳本,在目
文件夾根下執行svn update操作,將更新內容同步到測試環境,這樣開發調試非常方便。

post-commit內容:
--------------------------------------------
#!/bin/sh
#修改為服務編碼
export LANG=zh_CN.gb2312

#Set variable
REPOS="$1"
REV="$2"

SVN=/usr/bin/svn
WEB=/data/home/htdocs
LOG=/data/home/auto_svn.log

#update the code from the SVN
$SVN update $WEB --username username --password password --non-interactive

#......................
if [ $? == 0 ]
then

echo "$REPOS" "$REV" >> $LOG
echo `date` >> $LOG
echo "##############################" >> $LOG
fi
-----------------------------------------------
需要注意:
1、需要用export指定編碼。
2、需要指定svn全路徑。
3、代碼CO出來之後,可以進行post-commit腳本的測試了。因為svn的hooks執行的時候不帶有任何的環境變數,所以我們不能通過簡單的 ./post-commit 進行代碼的測試。必須要使用sudo su 等命令切換到svn或者apache伺服器運行用戶下,用下面的方法進行測試
Python代碼
env – ./post-commit
==================================================================================
#!/bin/bash
export LANG=en_US.UTF-8
src=/data/webroot/ask.j1.com ##local checkout directory###
deswebroot=/data/wwwroot/ask
remoteip=210.14.70.4
/usr/local/svn/bin/svn update $src --username webapp --password | grep -v -i update|awk '{print $2}'| while read chfile
do
if [ -e $chfile ];then
if [ -f $chfile ];then
#chown ftp.ftp $chfile
dfile=$(echo $chfile |sed "s:$src\/::") ###only file name###
rsync -avz -e ssh --exclude-from=/data/svndata/ask.j1.com/exclude-file $src/$dfile root@$remoteip:$deswebroot/$dfile
else
#chown ftp.ftp $chfile
dfile=$(echo $chfile |sed "s:$src\/::")
rsync -auvz -e ssh --exclude-from=/data/svndata/ask.j1.com/exclude-file $src/$dfile/ root@$remoteip:$deswebroot/$dfile/
fi
fi
done

『拾』 svn如何一次提交到兩個伺服器

svn提交只能直接提交到一個主伺服器,但是可以在主伺服器上增加一個hook腳本,處罰另外一個鏡像伺服器執行svnsync來同步本次提交

熱點內容
騰訊雲伺服器1mb老掉線 發布:2024-03-29 01:56:11 瀏覽:213
執行sql語句的存儲過程 發布:2024-03-29 01:52:37 瀏覽:695
婚紗攝影腳本 發布:2024-03-29 01:47:40 瀏覽:899
我的世界伺服器咋開外掛 發布:2024-03-29 01:07:45 瀏覽:455
sql寫報表 發布:2024-03-29 01:03:23 瀏覽:305
家用伺服器怎麼選 發布:2024-03-29 00:49:18 瀏覽:401
Ap6510dn如何配置 發布:2024-03-29 00:38:47 瀏覽:333
安卓和蘋果哪個更佔用內存 發布:2024-03-29 00:37:02 瀏覽:424
編譯錯誤算bug嗎 發布:2024-03-29 00:23:03 瀏覽:34
c語言干什麼 發布:2024-03-29 00:05:35 瀏覽:314