public function getBlame($file)
    {
        $blame = array();
        $logs = $this->getClient()->run($this, "blame -s $file");
        $logs = explode("\n", $logs);

        $i = 0;
        $previousCommit = '';
        foreach ($logs as $log) {
            if ('' == $log) {
                continue;
            }

            preg_match_all("/([a-zA-Z0-9^]{8})\s+.*?([0-9]+)\)(.+)/", $log, $match);

            $currentCommit = $match[1][0];
            if ($currentCommit != $previousCommit) {
                $i++;
                $blame[$i] = array('line' => '', 'commit' => $currentCommit);
            }

            $blame[$i]['line'] .= PHP_EOL . $match[3][0];
            $previousCommit = $currentCommit;
        }

        return $blame;
    }
public function getBlame($file)
    {
        $blame = array();
        $logs = $this->getClient()->run($this, "blame -s $file");
        $logs = explode("\n", $logs);

        $i = 0;
        $previousCommit = '';
        foreach ($logs as $log) {
            if ('' == $log) {
                continue;
            }

            preg_match_all("/([a-zA-Z0-9^]{8})\s+.*?([0-9]+)\)(.+)/", $log, $match);

            $currentCommit = $match[1][0];
            if ($currentCommit != $previousCommit) {
                $i++;
                $blame[$i] = array('line' => '', 'commit' => $currentCommit);
            }

            $blame[$i]['line'] .= PHP_EOL . $match[3][0];
            $previousCommit = $currentCommit;
        }

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

@param  string $file File that will be blamed

@return array  Commits hashes containing the lines
Blames the provided file and parses the output .