public function getBlame($file)
{
$blame = [];
$logs = $this->getClient()->run($this, "blame --root -sl {$file}");
$logs = explode("\n", $logs);
$i = 0;
$previousCommit = '';
foreach ($logs as $log) {
if ($log == '') {
continue;
}
preg_match_all("/([a-zA-Z0-9]{40})\\s+.*?([0-9]+)\\)(.+)/", $log, $match);
$currentCommit = $match[1][0];
if ($currentCommit != $previousCommit) {
++$i;
$blame[$i] = ['line' => '', 'commit' => $currentCommit, 'commitShort' => substr($currentCommit, 0, 8)];
}
$blame[$i]['line'] .= $match[3][0] . PHP_EOL;
$previousCommit = $currentCommit;
}
return $blame;
}