Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): rebaseWhen = automerging #31527

Merged
merged 58 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0c8f60f
fix(worker): don't coerce valid semver versions
viceice Jun 5, 2023
a41862e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 12, 2023
ebdbd00
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 24, 2023
f963606
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 2, 2023
89fa0b8
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 3, 2023
b7837af
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 8, 2023
4634ff3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 9, 2023
aeba91b
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 15, 2023
3d430bf
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 16, 2023
5b94272
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 21, 2023
ca8bce3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 21, 2023
64fe0cf
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Sep 14, 2023
5a8aed2
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Oct 26, 2023
d7ded40
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 1, 2023
602a2df
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 16, 2023
a002cbb
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 21, 2023
0864d5e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Feb 4, 2024
9c4c2c1
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Mar 3, 2024
6fa5fc3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Mar 14, 2024
e9f6bb7
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Apr 2, 2024
a6d9d2f
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 7, 2024
7d0e609
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 15, 2024
cad83ed
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 22, 2024
0743eda
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 22, 2024
0ab6813
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 26, 2024
a477e91
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 27, 2024
7fa2fff
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 14, 2024
9b1e584
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 17, 2024
1707e7e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 28, 2024
7a6109e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 13, 2024
f0bf475
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 25, 2024
d527d0b
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Sep 10, 2024
4e7c0f4
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Sep 16, 2024
377c22f
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Sep 22, 2024
5027f9b
rebaseWhen support automerging
PhilipAbed Sep 22, 2024
7037c87
honor keep updated
PhilipAbed Sep 22, 2024
43dcf46
honor keep updated
PhilipAbed Sep 22, 2024
540d146
honor keep updated
PhilipAbed Sep 22, 2024
3b76ab8
Merge branch 'main' into rebase-automerging
nabeelsaabna Oct 15, 2024
07d9307
honor keep updated
PhilipAbed Oct 22, 2024
3182e68
Merge branch 'rebase-automerging' of https://github.com/PhilipAbed/re…
PhilipAbed Oct 22, 2024
9b36d1b
honor automerging behind base branch
PhilipAbed Oct 22, 2024
bcbe43e
honor automerging behind base branch
PhilipAbed Oct 22, 2024
25b2ee9
refactor this
PhilipAbed Oct 28, 2024
7f506b1
refactor this
PhilipAbed Oct 28, 2024
29b1df0
pretty
PhilipAbed Oct 28, 2024
1acb56f
pretty
PhilipAbed Oct 28, 2024
898639d
small refactor for rebaseWhen value setter
PhilipAbed Oct 28, 2024
5ba81a0
small refactor for rebaseWhen value setter
PhilipAbed Oct 28, 2024
ec785f5
merge refactor with main
PhilipAbed Oct 28, 2024
d2fcf5d
prettier
PhilipAbed Oct 28, 2024
48b2d2f
fix conflicts
PhilipAbed Oct 29, 2024
a52197e
merge main
PhilipAbed Oct 30, 2024
c5cbd55
calculate rebaseWhen in one place only.
PhilipAbed Oct 30, 2024
70fe92d
remove tests
PhilipAbed Oct 30, 2024
89c8b34
early return
PhilipAbed Oct 30, 2024
3ecb7ea
early return remove
PhilipAbed Oct 30, 2024
e69fc5c
fix the condition order
PhilipAbed Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3628,6 +3628,7 @@ By default this label is `"rebase"` but you can configure it to anything you wan
Possible values and meanings:

- `auto`: Renovate will autodetect the best setting. It will use `behind-base-branch` if configured to automerge or repository has been set to require PRs to be up to date. Otherwise, `conflicted` will be used instead
- `automerging`: Renovate will use `behind-base-branch` if configured to automerge, Otherwise, `never` will be used instead
- `never`: Renovate will never rebase the branch or update it unless manually requested
- `conflicted`: Renovate will rebase only if the branch is conflicted
- `behind-base-branch`: Renovate will rebase whenever the branch falls 1 or more commit behind its base branch
Expand Down
8 changes: 7 additions & 1 deletion lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,13 @@ const options: RenovateOptions[] = [
name: 'rebaseWhen',
description: 'Controls when Renovate rebases an existing branch.',
type: 'string',
allowedValues: ['auto', 'never', 'conflicted', 'behind-base-branch'],
allowedValues: [
'auto',
'never',
'conflicted',
'behind-base-branch',
'automerging',
],
default: 'auto',
},
{
Expand Down
37 changes: 37 additions & 0 deletions lib/workers/repository/update/branch/reuse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,43 @@ describe('workers/repository/update/branch/reuse', () => {
expect(result.rebaseWhen).toBe('conflicted');
});

it('converts rebaseWhen=automerging to behind-base-branch', async () => {
config.rebaseWhen = 'automerging';
config.automerge = true;
scm.branchExists.mockResolvedValueOnce(true);
scm.isBranchBehindBase.mockResolvedValueOnce(false);

const result = await shouldReuseExistingBranch(config);

expect(config.rebaseWhen).toBe('automerging');
expect(result.rebaseWhen).toBe('behind-base-branch');
});

it('converts rebaseWhen=automerging to behind-base-branch if keep-updated', async () => {
config.rebaseWhen = 'automerging';
config.keepUpdatedLabel = 'keep-updated';
config.automerge = false;
scm.branchExists.mockResolvedValueOnce(true);
scm.isBranchBehindBase.mockResolvedValueOnce(false);
platform.getBranchPr.mockResolvedValueOnce(pr);

const result = await shouldReuseExistingBranch(config);

expect(config.rebaseWhen).toBe('automerging');
expect(result.rebaseWhen).toBe('behind-base-branch');
});

it('converts rebaseWhen=automerging to never', async () => {
config.rebaseWhen = 'automerging';
scm.branchExists.mockResolvedValueOnce(true);
scm.isBranchBehindBase.mockResolvedValueOnce(false);

const result = await shouldReuseExistingBranch(config);

expect(config.rebaseWhen).toBe('automerging');
expect(result.rebaseWhen).toBe('never');
});

it('converts rebaseWhen=auto to behind-base-branch if automerge is true AND branch is new', async () => {
config.rebaseWhen = 'auto';
config.automerge = true;
Expand Down
12 changes: 7 additions & 5 deletions lib/workers/repository/update/branch/reuse.ts
PhilipAbed marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function shouldReuseExistingBranch(
}

/**
* This method updates rebaseWhen value when it's set to auto(default)
* This method updates rebaseWhen value when it's set to auto(default) or automerging
*
* @param result BranchConfig
* @param keepUpdated boolean
Expand All @@ -122,16 +122,18 @@ async function determineRebaseWhenValue(
result: BranchConfig,
keepUpdated: boolean,
): Promise<void> {
if (result.rebaseWhen === 'auto') {
if (result.rebaseWhen === 'auto' || result.rebaseWhen === 'automerging') {
let reason;

let newValue = 'behind-base-branch';
if (result.automerge === true) {
reason = 'automerge=true';
} else if (await platform.getBranchForceRebase?.(result.baseBranch)) {
reason = 'platform is configured to require up-to-date branches';
} else if (keepUpdated) {
reason = 'keep-updated label is set';
} else if (result.rebaseWhen === 'automerging') {
newValue = 'never';
reason = 'no keep-updated label and automerging is set';
PhilipAbed marked this conversation as resolved.
Show resolved Hide resolved
} else if (await platform.getBranchForceRebase?.(result.baseBranch)) {
reason = 'platform is configured to require up-to-date branches';
} else {
newValue = 'conflicted';
reason = 'no rule for behind-base-branch applies';
Expand Down