Subversion Post Commit Hook

1. Create post-commit hook
[codesyntax lang="bash" lines="no" container="pre" tab_width="4"]
$ cd /data/svndata/hooks
$ cp post-commit.tmpl post-commit
$ chown kim:kim post-commit
$ chmod a+x post-commit
$ vi post-commit
[/codesyntax]
2. Hook with Shell [codesyntax lang="bash" lines="no" container="pre" tab_width="4"]
#!/bin/sh
export LANG=zh_CN.UTF-8
SVN=/usr/local/svn/bin/svn
WEB=/data/public_html
$SVN update $WEB --username kim --password mypass
chown -R nobody:nobody $WEB
[/codesyntax]
3. Hook with PHP [codesyntax lang="bash" lines="no" container="pre" tab_width="4"]
#!/bin/bash
REPOS="$1"
REV="$2"
export LANG=zh_CN.UTF-8
changed=$(svnlook changed -r $REV $REPOS)
log=$(svnlook log -r $REV $REPOS)
/usr/local/webserver/php/bin/php-cgi -q /data/vhosts/shell/svn_post_commit.php "$changed" &
[/codesyntax]
[codesyntax lang="bash" lines="no" container="pre" tab_width="4"]
$ vi /data/vhosts/shell/svn_post_commit.php
[/codesyntax]
[codesyntax lang="php" lines="no" container="pre" tab_width="4"]
$changed = '/data/vhosts/myproj';
$cmd = "svn up $changed;";
@exec($cmd);
exit;
[/codesyntax]
Posted in SVN| Tagged |
  1. 都是代码,还真看不懂

  2. 没有啊,我看得懂哦