Gush\Helper\GitHelper::getLogBetweenCommits PHP Method

getLogBetweenCommits() public method

Returned result is an array like: [ ['sha' => '...', 'author' => '...', 'subject' => '...', 'message' => '...'], ] Note; - Commits are by default returned in order of oldest to newest. - sha is the full commit-hash - author is the author name and e-mail address like "My Name " - Message contains the subject followed by two new lines and the actual message-body. Or an empty array when there are no logs.
public getLogBetweenCommits ( string $start, string $end ) : array[] | array
$start string
$end string
return array[] | array
    public function getLogBetweenCommits($start, $end)
    {
        // First we get all the commits, then of each commit we get the actual data
        // We can't the commit data in one go because the body contains newlines
        $commits = StringUtil::splitLines($this->processHelper->runCommand(['git', '--no-pager', 'log', '--oneline', '--no-color', '--format=%H', '--reverse', $start . '..' . $end]));
        return array_map(function ($commitHash) {
            // 0=author, 1=subject, anything higher then 2 is the full body
            $commitData = StringUtil::splitLines($this->processHelper->runCommand(['git', '--no-pager', 'show', '--format=%an <%ae>%n%s%n%b', '--no-color', '--no-patch', $commitHash]));
            return ['sha' => $commitHash, 'author' => array_shift($commitData), 'subject' => $commitData[0], 'message' => array_shift($commitData) . "\n\n" . implode("\n", $commitData)];
        }, $commits);
    }