最近项目有需求需要定期svn更新项目,并打包成下载包供下载,参考了网上的一些相关代码后写了如下一个用来进行svn操作的小组件
关于php进行zip打包的组件:http://blog.csdn.net/meeeen7/article/details/78297467
关于php进行download下载的组件:http://blog.csdn.net/meeeen7/article/details/78297528
define('SVN_USERNAME','');
define('SVN_PASSWORD','');
class svnUtil {
/**
* List directory entries in the repository
*
* @param string a specific project repository path
* @return bool true, if validated successfully, otherwise false
*/
static public function ls($repository) {
$command = "svn ls " . $repository;
$output = svnUtil::runCmd($command);
$output = implode("<br>", $output);
if (strpos($output, 'non-existent in that revision')) {
return false;
}
return "<br>" . $command . "<br>" . $output;
}
/**
* Duplicate something in working copy or repository, remembering history
*
* @param $src
* @param $dst
* @param $comment string specify log message
* @return bool true, if copy successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function copy($src, $dst, $comment) {
$command = "svn cp $src $dst -m '$comment'";
$output = svnUtil::runCmd($command);
$output = implode("<br>", $output);
if (strpos($output, 'Committ