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'));
}