private function buildFileHistory(GitRepository $git)
    {
        $filePath = $this->getFilePathCollection($this->currentPath);

        // If the commit history only merges,
        // then use the last merge commit for find the renaming file for follow the history.
        if (\count((array) $filePath['commits']) === $this->countMergeCommits($filePath['commits'])) {
            $commit = $filePath['commits'][\array_reverse(\array_keys($filePath['commits']))[0]];
            if ($this->isMergeCommit($commit)) {
                $parents = \explode(' ', $commit['parent']);

                $arguments = [
                    $git->getConfig()->getGitExecutablePath(),
                    'diff',
                    $commit['commit'],
                    $parents[1],
                    '--diff-filter=R',
                    '--name-status',
                    '--format=',
                    '-M'
                ];

                // git diff currentCommit rightCommit --diff-filter=R --name-status --format='' -M
                $matches = $this->matchFileInformation($this->runCustomGit($arguments, $git));
                foreach ($matches as $match) {
                    if (!\in_array($this->currentPath, $match)) {
                        continue;
                    }

                    $this->currentPath = $match['to'];
                    $filePath          = $this->getFilePathCollection($this->currentPath);
                    break;
                }
            }
        }

        $fileHistory = $this->fetchFileHistory($this->currentPath, $git);
        if (!\count($fileHistory)) {
            return;
        }

        foreach ($fileHistory as $pathHistory) {
            $filePath['pathHistory'][\md5($pathHistory)] = $this->getFilePathCollection($pathHistory);
        }

        $this->setFilePathCollection($this->currentPath, $filePath);
    }
private function buildFileHistory(GitRepository $git)
    {
        $filePath = $this->getFilePathCollection($this->currentPath);

        // If the commit history only merges,
        // then use the last merge commit for find the renaming file for follow the history.
        if (\count((array) $filePath['commits']) === $this->countMergeCommits($filePath['commits'])) {
            $commit = $filePath['commits'][\array_reverse(\array_keys($filePath['commits']))[0]];
            if ($this->isMergeCommit($commit)) {
                $parents = \explode(' ', $commit['parent']);

                $arguments = [
                    $git->getConfig()->getGitExecutablePath(),
                    'diff',
                    $commit['commit'],
                    $parents[1],
                    '--diff-filter=R',
                    '--name-status',
                    '--format=',
                    '-M'
                ];

                // git diff currentCommit rightCommit --diff-filter=R --name-status --format='' -M
                $matches = $this->matchFileInformation($this->runCustomGit($arguments, $git));
                foreach ($matches as $match) {
                    if (!\in_array($this->currentPath, $match)) {
                        continue;
                    }

                    $this->currentPath = $match['to'];
                    $filePath          = $this->getFilePathCollection($this->currentPath);
                    break;
                }
            }
        }

        $fileHistory = $this->fetchFileHistory($this->currentPath, $git);
        if (!\count($fileHistory)) {
            return;
        }

        foreach ($fileHistory as $pathHistory) {
            $filePath['pathHistory'][\md5($pathHistory)] = $this->getFilePathCollection($pathHistory);
        }

        $this->setFilePathCollection($this->currentPath, $filePath);
    }
private function buildFileHistory ( GitRepository $ git ) { $ filePath = $ this -> getFilePathCollection ( $ this -> currentPath ) ; // If the commit history only merges, // then use the last merge commit for find the renaming file for follow the history. if ( \ count ( ( array ) $ filePath [ 'commits' ] ) === $ this -> countMergeCommits ( $ filePath [ 'commits' ] ) ) { $ commit = $ filePath [ 'commits' ] [ \ array_reverse ( \ array_keys ( $ filePath [ 'commits' ] ) ) [ 0 ] ] ; if ( $ this -> isMergeCommit ( $ commit ) ) { $ parents = \ explode ( ' ' , $ commit [ 'parent' ] ) ; $ arguments = [ $ git -> getConfig ( ) -> getGitExecutablePath ( ) , 'diff' , $ commit [ 'commit' ] , $ parents [ 1 ] , '--diff-filter=R' , '--name-status' , '--format=' , '-M' ] ; // git diff currentCommit rightCommit --diff-filter=R --name-status --format='' -M $ matches = $ this -> matchFileInformation ( $ this -> runCustomGit ( $ arguments , $ git ) ) ; foreach ( $ matches as $ match ) { if ( ! \ in_array ( $ this -> currentPath , $ match ) ) { continue ; } $ this -> currentPath = $ match [ 'to' ] ; $ filePath = $ this -> getFilePathCollection ( $ this -> currentPath ) ; break ; } } } $ fileHistory = $ this -> fetchFileHistory ( $ this -> currentPath , $ git ) ; if ( ! \ count ( $ fileHistory ) ) { return ; } foreach ( $ fileHistory as $ pathHistory ) { $ filePath [ 'pathHistory' ] [ \ md5 ( $ pathHistory ) ] = $ this -> getFilePathCollection ( $ pathHistory ) ; } $ this -> setFilePathCollection ( $ this -> currentPath , $ filePath ) ; }
Build the file history.

@param GitRepository $git The git repository.

@return void
Build the file history .