Gush\Helper\GitHelper::mergeBranchWithLog PHP Method

mergeBranchWithLog() public method

Same as mergeBranch() but appends a commits log to the merge message.
public mergeBranchWithLog ( string $base, string $sourceBranch, string $commitMessage, string $sourceBranchLabel = null ) : string
$base string The base branch name
$sourceBranch string The source branch name
$commitMessage string Commit message to use for the merge-commit
$sourceBranchLabel string Actual branch (to use as replacement for the log) Else the temp-branch name is used.
return string The merge-commit hash
    public function mergeBranchWithLog($base, $sourceBranch, $commitMessage, $sourceBranchLabel = null)
    {
        $this->guardWorkingTreeReady();
        $this->stashBranchName();
        $this->checkout($base);
        if (null === $sourceBranchLabel) {
            $sourceBranchLabel = $sourceBranch;
        }
        $this->processHelper->runCommand(['git', 'merge', '--no-ff', '--log', '--no-commit', $sourceBranch]);
        // Extract commits log
        $commitMessage .= preg_replace('/^([^\\n]+)\\n\\n\\* ([^\\n]+):/', "\n\n* {$sourceBranchLabel}:", file_get_contents(getcwd() . '/.git/MERGE_MSG'));
        $tmpName = $this->filesystemHelper->newTempFilename();
        file_put_contents($tmpName, $commitMessage);
        $this->processHelper->runCommand(['git', 'commit', '-F', $tmpName]);
        return trim($this->processHelper->runCommand('git rev-parse HEAD'));
    }