svn hooks/post-commit 同步更新到web服务器

post-commit

#!/bin/sh
#库路径
REPOS="$1"
#版本号
REV="$2"
#改动的文件
changed=$(svnlook changed -r $REV $REPOS)
#用php脚本执行update
/usr/local/webserver/php/bin/php /data/shell/svn_post_commit_resources.php "$changed" &

svn_post_commit_resources.php

<?php
$files = explode("\n", $argv[1]);
if (!is_array($files)) {$files=(array)$files;};

foreach ($files as $v)
{
        // 取文件名
        $f_tem = trim(substr($v, 2));
        // 取最顶层目录名
         $d_tem = substr($f_tem, 0, strpos($f_tem, '/'));

         // SVN copy 对应的文件
          $f_name = '/data/www/yaf/' . $f_tem;
        $cmd = "svn update '$f_name' --username da --password sdfsdf;chown w    ww.www '$f_name'";

        exec($cmd);
}


你可能感兴趣的:(SVN)