예제 #1
0
파일: Svn.php 프로젝트: ShuangRen/walle-web
 /**
  * 获取提交历史
  *
  * @return array
  */
 public function getCommitList($branch = 'master', $count = 30)
 {
     // 先更新
     $destination = Project::getDeployFromDir();
     $this->updateRepo($branch, $destination);
     $cmd[] = sprintf('cd %s ', static::getBranchDir($branch, $this->getConfig()->repo_mode == Project::REPO_TAG ?: false));
     $cmd[] = $this->_getSvnCmd('svn log --xml -l' . $count);
     $command = join(' && ', $cmd);
     $result = $this->runLocalCommand($command);
     if (!$result) {
         throw new \Exception('获取提交历史失败:' . $this->getExeLog());
     }
     // 总有一些同学没有团队协作意识,不设置好编码:(
     $log = GlobalHelper::convert2Utf8($this->getExeLog());
     return array_values(static::formatXmlLog($log));
 }
예제 #2
0
파일: Git.php 프로젝트: 9618211/walle-web
 /**
  * 获取提交历史
  *
  * @return array
  */
 public function getCommitList($branch = 'master', $count = 20)
 {
     // 先更新
     $destination = Project::getDeployFromDir();
     $this->updateRepo($branch, $destination);
     $cmd[] = sprintf('cd %s ', $destination);
     $cmd[] = '/usr/bin/env git log -' . $count . ' --pretty="%h - %an %s" ';
     $command = join(' && ', $cmd);
     $result = $this->runLocalCommand($command);
     if (!$result) {
         throw new \Exception(\yii::t('walle', 'get commit log failed') . $this->getExeLog());
     }
     $history = [];
     // 总有一些同学没有团队协作意识,不设置好编码:(
     $log = GlobalHelper::convert2Utf8($this->getExeLog());
     $list = explode(PHP_EOL, $log);
     foreach ($list as $item) {
         $commitId = substr($item, 0, strpos($item, '-') - 1);
         $history[] = ['id' => $commitId, 'message' => $item];
     }
     return $history;
 }
예제 #3
0
파일: Git.php 프로젝트: ashehui/walle-web
 /**
  * 获取提交历史
  *
  * @param string $branch
  * @param int $count
  * @return array
  * @throws \Exception
  */
 public function getCommitList($branch = 'master', $count = 20)
 {
     // 先更新
     $destination = Project::getDeployFromDir();
     $this->updateRepo($branch, $destination);
     $cmd[] = sprintf('cd %s ', $destination);
     $cmd[] = '/usr/bin/env git log -' . $count . ' --pretty="%h_%s → %an" ';
     $command = join(' && ', $cmd);
     $result = $this->runLocalCommand($command);
     if (!$result) {
         throw new \Exception(\yii::t('walle', 'get commit log failed') . $this->getExeLog());
     }
     $history = [];
     // 总有一些同学没有团队协作意识,不设置好编码:(
     $log = htmlspecialchars(GlobalHelper::convert2Utf8($this->getExeLog()));
     $list = explode(PHP_EOL, $log);
     foreach ($list as $item) {
         if (preg_match('~^([A-Fa-f0-9]+)~', $item, $matches)) {
             $commitId = $matches[1];
         } else {
             $commitId = item;
         }
         $history[] = ['id' => $commitId, 'message' => $item];
     }
     return $history;
 }