1.进入到你创建的版本库目录下面,目录结构大致如下
drwxr-xr-x 2 root root 4096 Mar 16 00:18 conf
drwxr-sr-x 6 root root 4096 Apr 12 15:11 db
-r--r--r-- 1 root root 2 Mar 16 00:12 format
drwxr-xr-x 2 root root 4096 Mar 23 17:30 hooks
drwxr-xr-x 2 root root 4096 Mar 16 00:12 locks
-rw-r--r-- 1 root root 229 Mar 16 00:12 README.txt
2. 进入 hooks 目录下,这里就是我们能够使用的所有钩子。要实现我的需求,只需要 post-commit.tmpl 这一个,也就是使用 svn 客户端成功提交到仓库之后要执行的操作
[root@xxxxxx hooks]# ls -l
total 40
-rw-r--r-- 1 root root 1977 Mar 22 17:15 post-commit.tmpl
-rw-r--r-- 1 root root 1638 Mar 16 00:12 post-lock.tmpl
-rw-r--r-- 1 root root 2289 Mar 16 00:12 post-revprop-change.tmpl
-rw-r--r-- 1 root root 1567 Mar 16 00:12 post-unlock.tmpl
-rw-r--r-- 1 root root 3432 Mar 16 00:12 pre-commit.tmpl
-rw-r--r-- 1 root root 2416 Mar 16 00:12 pre-lock.tmpl
-rw-r--r-- 1 root root 2786 Mar 16 00:12 pre-revprop-change.tmpl
-rw-r--r-- 1 root root 2106 Mar 16 00:12 pre-unlock.tmpl
-rw-r--r-- 1 root root 2780 Mar 16 00:12 start-commit.tmpl
3.之后如下操作
[root@xxxxxx hooks]# cp post-commit.tmpl post-commit
[root@xxxxxx hooks]# vim post-commit
4.定位到文件底部(G),去除自带的使用示例,根据个人需求,追加如下内容 保存退出
SVN=/usr/local/bin/svn
WEB=/www/demo.xxx.net/
export.UTF-8
$SVN update $WEB --username xxoo--password xxoo
chown -Rf www:www $WEB
chmod -Rf 755 $WEB
5.最后赋予 post-commit 可执行权限
[root@xxxxxx hooks]# chmod u+x post-commit