Gush\Helper\GitHelper::switchBranchBase PHP Method

switchBranchBase() public method

public switchBranchBase ( $branchName, $currentBase, $newBase, $newBranchName = null )
    public function switchBranchBase($branchName, $currentBase, $newBase, $newBranchName = null)
    {
        $this->guardWorkingTreeReady();
        $this->stashBranchName();
        $this->checkout($branchName);
        if ($newBranchName) {
            // Switch to new branch so we can apply the rebase on the new branch
            $this->checkout($newBranchName, true);
        } else {
            $newBranchName = $branchName;
        }
        try {
            $this->processHelper->runCommand(['git', 'rebase', '--onto', $newBase, $currentBase, $newBranchName]);
        } catch (\Exception $e) {
            // Error, abort the rebase process
            $this->processHelper->runCommand(['git', 'rebase', '--abort'], true);
            $this->restoreStashedBranch();
            throw new \RuntimeException('Git rebase failed to switch base.', 0, $e);
        }
    }