Skip to content

Commit 93afa9f

Browse files
authored
fix(github): respect automergeStrategy with platform automerge (#44563)
* fix(github): respect automerge strategy with platform automerge * docs(automerge): clarify GitHub platform strategy * docs(automerge): generalize platform strategy behavior
1 parent 0216124 commit 93afa9f

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

docs/usage/configuration-options.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ If possible, Renovate follows the merge strategy set on the platform itself for
303303
If you've set `automerge=true` and `automergeType=pr` for any of your dependencies, then you may choose what automerge strategy Renovate uses by setting the `automergeStrategy` config option.
304304
If you're happy with the default behavior, you don't need to do anything.
305305

306+
On supported platforms, `automergeStrategy` also applies when using platform-native automerge.
307+
306308
You may choose from these values:
307309

308310
- `auto`, Renovate decides how to merge
@@ -4067,6 +4069,8 @@ If enabled Renovate will pin Docker images or GitHub Actions by means of their S
40674069

40684070
If you have enabled `automerge` and set `automergeType=pr` in the Renovate config, then leaving `platformAutomerge` as `true` speeds up merging via the platform's native automerge functionality.
40694071

4072+
Where supported, platform-native automerge uses [`automergeStrategy`](#automergestrategy) to select the merge method.
4073+
40704074
On Bitbucket Server, GitHub and GitLab, Renovate re-enables the PR for platform-native automerge whenever it's rebased.
40714075

40724076
`platformAutomerge` will configure PRs to be merged after all (if any) branch policies have been met.

lib/modules/platform/github/index.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4174,6 +4174,36 @@ describe('modules/platform/github/index', () => {
41744174
]);
41754175
});
41764176

4177+
it('should use the configured automerge strategy', async () => {
4178+
const scope = await mockScope();
4179+
scope.post('/graphql').reply(200, graphqlAutomergeResp);
4180+
4181+
const pr = await github.createPr({
4182+
...prConfig,
4183+
platformPrOptions: {
4184+
usePlatformAutomerge: true,
4185+
automergeStrategy: 'rebase',
4186+
},
4187+
});
4188+
4189+
expect(pr).toMatchObject({ number: 123 });
4190+
expect(httpMock.getTrace()).toMatchObject([
4191+
graphqlGetRepo,
4192+
restCreatePr,
4193+
restAddLabels,
4194+
{
4195+
...graphqlAutomerge,
4196+
graphql: {
4197+
...graphqlAutomerge.graphql,
4198+
variables: {
4199+
pullRequestId: 'abcd',
4200+
mergeMethod: 'REBASE',
4201+
},
4202+
},
4203+
},
4204+
]);
4205+
});
4206+
41774207
it('should handle GraphQL errors', async () => {
41784208
const scope = await mockScope();
41794209
scope.post('/graphql').reply(200, graphqlAutomergeErrorResp);

lib/modules/platform/github/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,11 @@ async function tryPrAutomerge(
18871887
}
18881888

18891889
try {
1890-
const mergeMethod = config.mergeMethod?.toUpperCase() || 'MERGE';
1890+
const mergeMethod =
1891+
(
1892+
mapMergeStartegy(platformPrOptions.automergeStrategy) ??
1893+
config.mergeMethod
1894+
)?.toUpperCase() || 'MERGE';
18911895

18921896
let commitHeadline: string | undefined;
18931897
let commitBody: string | undefined;

0 commit comments

Comments
 (0)