From 9f71f7e6ae79e86b12c7ad7563afdec670883c79 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sat, 27 Aug 2016 10:06:10 -0300 Subject: [PATCH] Add `git pull --rebase {base-branch}` call at `GitHelper::squashCommits()` --- src/Helper/GitHelper.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Helper/GitHelper.php b/src/Helper/GitHelper.php index 90163f36..eef59687 100644 --- a/src/Helper/GitHelper.php +++ b/src/Helper/GitHelper.php @@ -650,6 +650,16 @@ public function squashCommits($base, $branchName, $ignoreMultipleAuthors = false '-author' => $author, ] ); + + try { + // Ensure squashed commits don't introduce regressions at base branch + $this->processHelper->runCommand(['git', 'pull', '--rebase', $base]); + } catch (\Exception $e) { + // Error, abort the rebase process + $this->processHelper->runCommand(['git', 'rebase', '--abort'], true); + + throw new \RuntimeException(sprintf('Git rebase failed while trying to synchronize history against "%s".', $base), 0, $e); + } } public function syncWithRemote($remote, $branchName = null)