Skip to content

Commit 9f71f7e

Browse files
committed
Add git pull --rebase {base-branch} call at GitHelper::squashCommits()
1 parent 28b5ae9 commit 9f71f7e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Helper/GitHelper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,16 @@ public function squashCommits($base, $branchName, $ignoreMultipleAuthors = false
650650
'-author' => $author,
651651
]
652652
);
653+
654+
try {
655+
// Ensure squashed commits don't introduce regressions at base branch
656+
$this->processHelper->runCommand(['git', 'pull', '--rebase', $base]);
657+
} catch (\Exception $e) {
658+
// Error, abort the rebase process
659+
$this->processHelper->runCommand(['git', 'rebase', '--abort'], true);
660+
661+
throw new \RuntimeException(sprintf('Git rebase failed while trying to synchronize history against "%s".', $base), 0, $e);
662+
}
653663
}
654664

655665
public function syncWithRemote($remote, $branchName = null)

0 commit comments

Comments
 (0)