Gitamin\Services\Git\Repository::getCommit PHP Method

getCommit() public method

Show the data from a specific commit.
public getCommit ( string $commitHash ) : array
$commitHash string Hash of the specific commit to read data
return array Commit data
    public function getCommit($commitHash)
    {
        $logs = $this->getClient()->run($this, 'show --pretty=format:"<item><hash>%H</hash>' . '<short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents>' . '<author>%aN</author><author_email>%aE</author_email>' . '<date>%at</date><commiter>%cN</commiter><commiter_email>%cE</commiter_email>' . '<commiter_date>%ct</commiter_date>' . '<message><![CDATA[%s]]></message>' . '<body><![CDATA[%b]]></body>' . "</item>\" {$commitHash}");
        $xmlEnd = strpos($logs, '</item>') + 7;
        $commitInfo = substr($logs, 0, $xmlEnd);
        $commitData = substr($logs, $xmlEnd);
        $logs = explode("\n", $commitData);
        // Read commit metadata
        $format = new PrettyFormat();
        $data = $format->parse($commitInfo);
        $commit = new Commit();
        $commit->importData($data[0]);
        if ($commit->getParentsHash()) {
            $command = 'diff ' . $commitHash . '~1..' . $commitHash;
            $logs = explode("\n", $this->getClient()->run($this, $command));
        }
        $commit->setDiffs($this->readDiffLogs($logs));
        return $commit;
    }