Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Gitblame.php

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

Gitblame

Namespace

PHP_CodeSniffer\Reports

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal