Skip to content
Snippets Groups Projects
Unverified Commit 8e7e41f6 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix: rebase if automerging even if rebaseWhen=conflicted (#8796)

parent 4b62acc6
No related branches found
No related tags found
No related merge requests found
......@@ -159,14 +159,15 @@ describe(getName(__filename), () => {
expect(git.isBranchModified).not.toHaveBeenCalled();
});
it('returns true if automerge, rebaseWhen=conflicted and stale', async () => {
it('returns false if automerge, rebaseWhen=conflicted and stale', async () => {
config.rebaseWhen = 'conflicted';
config.automerge = true;
git.branchExists.mockReturnValueOnce(true);
git.isBranchStale.mockResolvedValueOnce(true);
const res = await shouldReuseExistingBranch(config);
expect(res.reuseExistingBranch).toBe(true);
expect(git.isBranchStale).not.toHaveBeenCalled();
expect(git.isBranchModified).not.toHaveBeenCalled();
expect(res.reuseExistingBranch).toBe(false);
expect(git.isBranchStale).toHaveBeenCalled();
expect(git.isBranchModified).toHaveBeenCalled();
});
});
});
......@@ -48,8 +48,8 @@ export async function shouldReuseExistingBranch(
if (
config.rebaseWhen === 'behind-base-branch' ||
(config.rebaseWhen === 'auto' &&
(config.automerge === true || (await platform.getRepoForceRebase())))
(config.rebaseWhen !== 'never' && config.automerge === true) ||
(config.rebaseWhen === 'auto' && (await platform.getRepoForceRebase()))
) {
if (await isBranchStale(branchName)) {
logger.debug(`Branch is stale and needs rebasing`);
......@@ -61,6 +61,9 @@ export async function shouldReuseExistingBranch(
}
return { reuseExistingBranch: false };
}
logger.debug('Branch is up-to-date');
} else {
logger.debug('Skipping stale branch check');
}
// Now check if PR is unmergeable. If so then we also rebase
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment