public function searchCommitLog($query, $branch)
{
$query = escapeshellarg($query);
$query = strtr($query, ['[' => '\\[', ']' => '\\]']);
$command = "log --grep={$query} -i --pretty=format:\"<item><hash>%H</hash>" . '<short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents>' . '<author>%aN</author><author_email>%aE</author_email>' . '<date>%at</date><commiter>%cN</commiter>' . '<commiter_email>%cE</commiter_email>' . '<commiter_date>%ct</commiter_date>' . '<message><![CDATA[%s]]></message></item>"' . " {$branch}";
try {
$logs = $this->getPrettyFormat($command);
} catch (\RuntimeException $e) {
return [];
}
foreach ($logs as $log) {
$commit = new Commit();
$commit->importData($log);
$commits[] = $commit;
}
return $commits;
}