diff --git a/lib/modules/platform/gitea/index.spec.ts b/lib/modules/platform/gitea/index.spec.ts index 1c1fc2b77e61f4..d4321b823be8f4 100644 --- a/lib/modules/platform/gitea/index.spec.ts +++ b/lib/modules/platform/gitea/index.spec.ts @@ -1217,6 +1217,81 @@ describe('modules/platform/gitea/index', () => { }); expect(helper.mergePR).not.toHaveBeenCalled(); }); + + it('should create PR with repository merge method when automergeStrategy is auto', async () => { + helper.createPR.mockResolvedValueOnce(mockNewPR); + await initFakePlatform('1.17.0'); + await initFakeRepo(); + await gitea.createPr({ + sourceBranch: mockNewPR.head.label, + targetBranch: 'master', + prTitle: mockNewPR.title, + prBody: mockNewPR.body, + platformOptions: { + automergeStrategy: 'auto', + usePlatformAutomerge: true, + }, + }); + + expect(helper.createPR).toHaveBeenCalledTimes(1); + expect(helper.createPR).toHaveBeenCalledWith(mockRepo.full_name, { + base: mockNewPR.base.ref, + head: mockNewPR.head.label, + title: mockNewPR.title, + body: mockNewPR.body, + labels: [], + }); + expect(helper.mergePR).toHaveBeenCalledWith( + mockRepo.full_name, + mockNewPR.number, + { + Do: 'rebase', + merge_when_checks_succeed: true, + }, + ); + }); + + it.each` + automergeStrategy | prMergeStrategy + ${'fast-forward'} | ${'rebase'} + ${'merge-commit'} | ${'merge'} + ${'rebase'} | ${'rebase-merge'} + ${'squash'} | ${'squash'} + `( + 'should create PR with mergeStrategy $prMergeStrategy', + async ({ automergeStrategy, prMergeStrategy }) => { + helper.createPR.mockResolvedValueOnce(mockNewPR); + await initFakePlatform('1.17.0'); + await initFakeRepo(); + await gitea.createPr({ + sourceBranch: mockNewPR.head.label, + targetBranch: 'master', + prTitle: mockNewPR.title, + prBody: mockNewPR.body, + platformOptions: { + automergeStrategy, + usePlatformAutomerge: true, + }, + }); + + expect(helper.createPR).toHaveBeenCalledTimes(1); + expect(helper.createPR).toHaveBeenCalledWith(mockRepo.full_name, { + base: mockNewPR.base.ref, + head: mockNewPR.head.label, + title: mockNewPR.title, + body: mockNewPR.body, + labels: [], + }); + expect(helper.mergePR).toHaveBeenCalledWith( + mockRepo.full_name, + mockNewPR.number, + { + Do: prMergeStrategy, + merge_when_checks_succeed: true, + }, + ); + }, + ); }); describe('updatePr', () => { diff --git a/lib/modules/platform/gitea/index.ts b/lib/modules/platform/gitea/index.ts index de33ac3623a889..923006afbbf9c5 100644 --- a/lib/modules/platform/gitea/index.ts +++ b/lib/modules/platform/gitea/index.ts @@ -544,8 +544,9 @@ const platform: Platform = { if (semver.gte(defaults.version, '1.17.0')) { try { await helper.mergePR(config.repository, gpr.number, { - // TODO: pass strategy (#16884) - Do: config.mergeMethod, + Do: + getMergeMethod(platformOptions?.automergeStrategy) ?? + config.mergeMethod, merge_when_checks_succeed: true, });