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 = htmlspecialchars(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;
}