function Gitblame::getBlameContent
Gets the blame output.
Parameters
string $filename File to blame.:
Return value
array
Throws
\PHP_CodeSniffer\Exceptions\DeepExitException
Overrides VersionControl::getBlameContent
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Reports/ Gitblame.php, line 68
Class
Namespace
PHP_CodeSniffer\ReportsCode
protected function getBlameContent($filename) {
$cwd = getcwd();
chdir(dirname($filename));
$command = 'git blame --date=short "' . basename($filename) . '" 2>&1';
$handle = popen($command, 'r');
if ($handle === false) {
$error = 'ERROR: Could not execute "' . $command . '"' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, 3);
}
$rawContent = stream_get_contents($handle);
pclose($handle);
$blames = explode("\n", $rawContent);
chdir($cwd);
return $blames;
}