app\components\Git::getTagList PHP Method

getTagList() public method

获取tag记录
public getTagList ( $count = 20 ) : array
return array
    public function getTagList($count = 20)
    {
        // 先更新
        $this->updateRepo();
        $destination = Project::getDeployFromDir();
        $cmd[] = sprintf('cd %s ', $destination);
        $cmd[] = '/usr/bin/env git tag -l ';
        $command = join(' && ', $cmd);
        $result = $this->runLocalCommand($command);
        if (!$result) {
            throw new \Exception(\yii::t('walle', 'get tags failed') . $this->getExeLog());
        }
        $history = [];
        $list = explode(PHP_EOL, $this->getExeLog());
        foreach ($list as $item) {
            $history[] = ['id' => $item, 'message' => $item];
        }
        return $history;
    }

Usage Example

Example #1
0
 /**
  * 获取commit历史
  *
  * @param $projectId
  */
 public function actionGetCommitHistory($projectId, $branch = 'master')
 {
     $git = new Git();
     $conf = Project::getConf($projectId);
     $git->setConfig($conf);
     if ($conf->git_type == Project::GIT_TAG) {
         $list = $git->getTagList();
     } else {
         $list = $git->getCommitList($branch);
     }
     $this->renderJson($list);
 }