Home > php教程 > php手册 > PHP运行SVN命令显示某用户的文件更新记录的代码

PHP运行SVN命令显示某用户的文件更新记录的代码

WBOY
Release: 2016-06-06 20:25:56
Original
1366 people have browsed it

使用SVN开发者们平时开发或代码上线过程中需要知道某个时间段内修改或添加过那些文件,所以用PHP写了个小程序,直接在浏览器中调用即可

复制代码 代码如下:


$user=trim($_GET['user']);
$d=$_GET['date'];
if(!$d){
 $d=date('Ymd',time()-86400*14);
}
if(empty($user)){
 echo "例如:svn_log.php?user=wang&date=20130118";
 exit;
}

$cmd='/usr/bin/svn log -v -r {'.$d.'}:"HEAD" --username 用户名 --password 密码 --no-auth-cache | sed -n "/'.$user.'/,/-----$/ p" 2>&1';

$p=dirname(__FILE__);

exec('cd '.$p,$output);

exec($cmd,$output);

$d=date('Y年m月d日',strtotime($d));
echo $user.'自'.$d.'以来:
';
echo '---------------------------------------------
';
$out='';

krsort($output);

if(!empty($output)){
 foreach($output as $v){
  $p1=strpos($v,'/branch/');
  $p2=strpos($v,'/tg/');
  if($p1!==false || $p2!==false){
   if($p1!==false){
    $v=substr($v,$p1+9);
   }else{
    $v=substr($v,$p2+4);
   }
   if($out==''){
    $out=$v;
    echo $v.'
';
   }else{
    if(strpos($out,$v)===false){
     $out.=','.$v;
     echo $v.'
';
    }
   }
  }
 }
}else{
 echo "没有文件";
}
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template