From 4b502025fedfbfa62379147445ccebff0144e3d0 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Tue, 16 Jul 2024 13:03:55 +0530 Subject: [PATCH] refactor: rename platformOptions -> platformPrOptions (#30173) --- .../azure/__snapshots__/index.spec.ts.snap | 10 +++--- lib/modules/platform/azure/index.spec.ts | 16 ++++----- lib/modules/platform/azure/index.ts | 16 ++++----- .../platform/bitbucket-server/index.spec.ts | 4 +-- .../platform/bitbucket-server/index.ts | 5 ++- lib/modules/platform/bitbucket/index.spec.ts | 14 ++++---- lib/modules/platform/bitbucket/index.ts | 4 +-- lib/modules/platform/gerrit/index.spec.ts | 6 ++-- lib/modules/platform/gerrit/index.ts | 4 +-- lib/modules/platform/gitea/index.spec.ts | 14 ++++---- lib/modules/platform/gitea/index.ts | 6 ++-- lib/modules/platform/github/index.spec.ts | 10 +++--- lib/modules/platform/github/index.ts | 14 ++++---- lib/modules/platform/gitlab/index.spec.ts | 34 +++++++++---------- lib/modules/platform/gitlab/index.ts | 20 +++++------ lib/modules/platform/types.ts | 6 ++-- .../repository/config-migration/pr/index.ts | 2 +- lib/workers/repository/onboarding/pr/index.ts | 2 +- lib/workers/repository/update/branch/index.ts | 6 ++-- lib/workers/repository/update/pr/index.ts | 4 +-- 20 files changed, 98 insertions(+), 99 deletions(-) diff --git a/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap b/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap index bc735f9bbdf952..e782de620ace85 100644 --- a/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap @@ -203,7 +203,7 @@ exports[`modules/platform/azure/index initRepo should initialise the config for } `; -exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOptions) should close the PR 1`] = ` +exports[`modules/platform/azure/index updatePr(prNo, title, body, platformPrOptions) should close the PR 1`] = ` [ [ { @@ -217,9 +217,9 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption ] `; -exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOptions) should re-approve the PR 1`] = `undefined`; +exports[`modules/platform/azure/index updatePr(prNo, title, body, platformPrOptions) should re-approve the PR 1`] = `undefined`; -exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOptions) should reopen the PR 1`] = ` +exports[`modules/platform/azure/index updatePr(prNo, title, body, platformPrOptions) should reopen the PR 1`] = ` [ [ { @@ -239,7 +239,7 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption ] `; -exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOptions) should update the PR 1`] = ` +exports[`modules/platform/azure/index updatePr(prNo, title, body, platformPrOptions) should update the PR 1`] = ` [ [ { @@ -253,7 +253,7 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption ] `; -exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOptions) should update the PR without description 1`] = ` +exports[`modules/platform/azure/index updatePr(prNo, title, body, platformPrOptions) should update the PR without description 1`] = ` [ [ { diff --git a/lib/modules/platform/azure/index.spec.ts b/lib/modules/platform/azure/index.spec.ts index a30bdfce5f370f..7f4257d8cc7dc3 100644 --- a/lib/modules/platform/azure/index.spec.ts +++ b/lib/modules/platform/azure/index.spec.ts @@ -925,7 +925,7 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(updateFn).toHaveBeenCalled(); expect(pr).toMatchSnapshot(); @@ -996,7 +996,7 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { + platformPrOptions: { automergeStrategy: 'auto', usePlatformAutomerge: true, }, @@ -1008,7 +1008,7 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Second Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { + platformPrOptions: { automergeStrategy: 'auto', usePlatformAutomerge: true, }, @@ -1061,7 +1061,7 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { + platformPrOptions: { automergeStrategy, usePlatformAutomerge: true, }, @@ -1113,7 +1113,7 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { + platformPrOptions: { automergeStrategy, usePlatformAutomerge: true, }, @@ -1163,14 +1163,14 @@ describe('modules/platform/azure/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { autoApprove: true }, + platformPrOptions: { autoApprove: true }, }); expect(updateFn).toHaveBeenCalled(); expect(pr).toMatchSnapshot(); }); }); - describe('updatePr(prNo, title, body, platformOptions)', () => { + describe('updatePr(prNo, title, body, platformPrOptions)', () => { it('should update the PR', async () => { await initRepo({ repository: 'some/repo' }); const updatePullRequest = jest.fn(); @@ -1272,7 +1272,7 @@ describe('modules/platform/azure/index', () => { number: prResult.pullRequestId, prTitle: 'The Title', prBody: 'Hello world', - platformOptions: { autoApprove: true }, + platformPrOptions: { autoApprove: true }, }); expect(updateFn).toHaveBeenCalled(); expect(pr).toMatchSnapshot(); diff --git a/lib/modules/platform/azure/index.ts b/lib/modules/platform/azure/index.ts index 36a2313632ad15..005214ba27a6a1 100644 --- a/lib/modules/platform/azure/index.ts +++ b/lib/modules/platform/azure/index.ts @@ -465,7 +465,7 @@ export async function createPr({ prBody: body, labels, draftPR = false, - platformOptions, + platformPrOptions, }: CreatePRConfig): Promise { const sourceRefName = getNewBranchName(sourceBranch); const targetRefName = getNewBranchName(targetBranch); @@ -473,7 +473,7 @@ export async function createPr({ const azureApiGit = await azureApi.gitApi(); const workItemRefs = [ { - id: platformOptions?.azureWorkItemId?.toString(), + id: platformPrOptions?.azureWorkItemId?.toString(), }, ]; let pr: GitPullRequest = await azureApiGit.createPullRequest( @@ -487,11 +487,11 @@ export async function createPr({ }, config.repoId, ); - if (platformOptions?.usePlatformAutomerge) { + if (platformPrOptions?.usePlatformAutomerge) { const mergeStrategy = - platformOptions.automergeStrategy === 'auto' + platformPrOptions.automergeStrategy === 'auto' ? await getMergeStrategy(pr.targetRefName!) - : mapMergeStrategy(platformOptions.automergeStrategy); + : mapMergeStrategy(platformPrOptions.automergeStrategy); pr = await azureApiGit.updatePullRequest( { autoCompleteSetBy: { @@ -509,7 +509,7 @@ export async function createPr({ pr.pullRequestId!, ); } - if (platformOptions?.autoApprove) { + if (platformPrOptions?.autoApprove) { await azureApiGit.createPullRequestReviewer( { reviewerUrl: pr.createdBy!.url, @@ -543,7 +543,7 @@ export async function updatePr({ prTitle: title, prBody: body, state, - platformOptions, + platformPrOptions, targetBranch, }: UpdatePrConfig): Promise { logger.debug(`updatePr(${prNo}, ${title}, body)`); @@ -572,7 +572,7 @@ export async function updatePr({ } else if (state === 'closed') { objToUpdate.status = PullRequestStatus.Abandoned; } - if (platformOptions?.autoApprove) { + if (platformPrOptions?.autoApprove) { const pr = await azureApiGit.getPullRequestById(prNo, config.project); await azureApiGit.createPullRequestReviewer( { diff --git a/lib/modules/platform/bitbucket-server/index.spec.ts b/lib/modules/platform/bitbucket-server/index.spec.ts index b980ab9f61c2ab..d11230612388a2 100644 --- a/lib/modules/platform/bitbucket-server/index.spec.ts +++ b/lib/modules/platform/bitbucket-server/index.spec.ts @@ -1487,7 +1487,7 @@ describe('modules/platform/bitbucket-server/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); @@ -1514,7 +1514,7 @@ describe('modules/platform/bitbucket-server/index', () => { prTitle: 'title', prBody: 'body', labels: null, - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); diff --git a/lib/modules/platform/bitbucket-server/index.ts b/lib/modules/platform/bitbucket-server/index.ts index caa5fc34b94efb..2e965bbab94e52 100644 --- a/lib/modules/platform/bitbucket-server/index.ts +++ b/lib/modules/platform/bitbucket-server/index.ts @@ -865,15 +865,14 @@ export async function createPr({ targetBranch, prTitle: title, prBody: rawDescription, - platformOptions, + platformPrOptions, }: CreatePRConfig): Promise { const description = sanitize(rawDescription); logger.debug(`createPr(${sourceBranch}, title=${title})`); const base = targetBranch; let reviewers: BbsRestUserRef[] = []; - /* istanbul ignore else */ - if (platformOptions?.bbUseDefaultReviewers) { + if (platformPrOptions?.bbUseDefaultReviewers) { logger.debug(`fetching default reviewers`); const { id } = ( await bitbucketServerHttp.getJson<{ id: number }>( diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index 66fd23ac131a2e..9de64419b236dc 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -1105,7 +1105,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); @@ -1188,7 +1188,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); @@ -1251,7 +1251,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); @@ -1297,7 +1297,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }), @@ -1352,7 +1352,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }); @@ -1391,7 +1391,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }), @@ -1430,7 +1430,7 @@ describe('modules/platform/bitbucket/index', () => { targetBranch: 'master', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { bbUseDefaultReviewers: true, }, }), diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index b47fcd4421f2e5..4ebd23684d6031 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -867,7 +867,7 @@ export async function createPr({ targetBranch, prTitle: title, prBody: description, - platformOptions, + platformPrOptions, }: CreatePRConfig): Promise { // labels is not supported in Bitbucket: https://bitbucket.org/site/master/issues/11976/ability-to-add-labels-to-pull-requests-bb @@ -877,7 +877,7 @@ export async function createPr({ let reviewers: Account[] = []; - if (platformOptions?.bbUseDefaultReviewers) { + if (platformPrOptions?.bbUseDefaultReviewers) { const reviewersResponse = ( await bitbucketHttp.getJson>( `/2.0/repositories/${config.repository}/effective-default-reviewers`, diff --git a/lib/modules/platform/gerrit/index.spec.ts b/lib/modules/platform/gerrit/index.spec.ts index 17ee4188cde69d..025f1d1e2e3f7e 100644 --- a/lib/modules/platform/gerrit/index.spec.ts +++ b/lib/modules/platform/gerrit/index.spec.ts @@ -225,7 +225,7 @@ describe('modules/platform/gerrit/index', () => { await gerrit.updatePr({ number: 123456, prTitle: 'subject', - platformOptions: { + platformPrOptions: { autoApprove: true, }, }); @@ -338,7 +338,7 @@ describe('modules/platform/gerrit/index', () => { targetBranch: 'target', prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { autoApprove: false, }, }); @@ -362,7 +362,7 @@ describe('modules/platform/gerrit/index', () => { targetBranch: 'target', prTitle: change.subject, prBody: 'body', - platformOptions: { + platformPrOptions: { autoApprove: true, }, }); diff --git a/lib/modules/platform/gerrit/index.ts b/lib/modules/platform/gerrit/index.ts index db740964fe60c9..20360a761d497d 100644 --- a/lib/modules/platform/gerrit/index.ts +++ b/lib/modules/platform/gerrit/index.ts @@ -168,7 +168,7 @@ export async function updatePr(prConfig: UpdatePrConfig): Promise { TAG_PULL_REQUEST_BODY, ); } - if (prConfig.platformOptions?.autoApprove) { + if (prConfig.platformPrOptions?.autoApprove) { await client.approveChange(prConfig.number); } if (prConfig.state && prConfig.state === 'closed') { @@ -211,7 +211,7 @@ export async function createPr(prConfig: CreatePRConfig): Promise { prConfig.prBody, TAG_PULL_REQUEST_BODY, ); - if (prConfig.platformOptions?.autoApprove) { + if (prConfig.platformPrOptions?.autoApprove) { await client.approveChange(pr._number); } return getPr(pr._number); diff --git a/lib/modules/platform/gitea/index.spec.ts b/lib/modules/platform/gitea/index.spec.ts index 61141ec63cb9f2..76be755c11e193 100644 --- a/lib/modules/platform/gitea/index.spec.ts +++ b/lib/modules/platform/gitea/index.spec.ts @@ -1625,7 +1625,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(res).toMatchObject({ @@ -1653,7 +1653,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(res).toMatchObject({ @@ -1681,7 +1681,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(res).toMatchObject({ @@ -1707,7 +1707,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(res).toMatchObject({ @@ -1734,7 +1734,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }); expect(res).toMatchObject({ @@ -1763,7 +1763,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { + platformPrOptions: { automergeStrategy: 'auto', usePlatformAutomerge: true, }, @@ -1802,7 +1802,7 @@ describe('modules/platform/gitea/index', () => { targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, - platformOptions: { + platformPrOptions: { automergeStrategy, usePlatformAutomerge: true, }, diff --git a/lib/modules/platform/gitea/index.ts b/lib/modules/platform/gitea/index.ts index 04232733965fe1..4e77ea1f04de7a 100644 --- a/lib/modules/platform/gitea/index.ts +++ b/lib/modules/platform/gitea/index.ts @@ -523,7 +523,7 @@ const platform: Platform = { prTitle, prBody: rawBody, labels: labelNames, - platformOptions, + platformPrOptions, draftPR, }: CreatePRConfig): Promise { let title = prTitle; @@ -547,12 +547,12 @@ const platform: Platform = { labels: labels.filter(is.number), }); - if (platformOptions?.usePlatformAutomerge) { + if (platformPrOptions?.usePlatformAutomerge) { if (semver.gte(defaults.version, '1.17.0')) { try { await helper.mergePR(config.repository, gpr.number, { Do: - getMergeMethod(platformOptions?.automergeStrategy) ?? + getMergeMethod(platformPrOptions?.automergeStrategy) ?? config.mergeMethod, merge_when_checks_succeed: true, }); diff --git a/lib/modules/platform/github/index.spec.ts b/lib/modules/platform/github/index.spec.ts index 4c1d2a51d0bbbb..a8a4b4694e3eb6 100644 --- a/lib/modules/platform/github/index.spec.ts +++ b/lib/modules/platform/github/index.spec.ts @@ -2744,7 +2744,7 @@ describe('modules/platform/github/index', () => { prTitle: 'PR title', prBody: 'PR can be edited by maintainers.', labels: null, - platformOptions: { + platformPrOptions: { forkModeDisallowMaintainerEdits: false, }, }); @@ -2789,7 +2789,7 @@ describe('modules/platform/github/index', () => { prTitle: 'PR title', prBody: 'PR *cannot* be edited by maintainers.', labels: null, - platformOptions: { + platformPrOptions: { forkModeDisallowMaintainerEdits: true, }, }); @@ -2831,7 +2831,7 @@ describe('modules/platform/github/index', () => { prTitle: 'The Title', prBody: 'Hello world', labels: ['deps', 'renovate'], - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }; const mockScope = async (repoOpts: any = {}): Promise => { @@ -3412,7 +3412,7 @@ describe('modules/platform/github/index', () => { }); }); - describe('reattemptPlatformAutomerge(number, platformOptions)', () => { + describe('reattemptPlatformAutomerge(number, platformPrOptions)', () => { const getPrListResp = [ { number: 1234, @@ -3440,7 +3440,7 @@ describe('modules/platform/github/index', () => { const pr: ReattemptPlatformAutomergeConfig = { number: 123, - platformOptions: { usePlatformAutomerge: true }, + platformPrOptions: { usePlatformAutomerge: true }, }; const mockScope = async (repoOpts: any = {}): Promise => { diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index a3457a0253869e..c0a95c1d6d2dcf 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -1659,9 +1659,9 @@ export async function ensureCommentRemoval( async function tryPrAutomerge( prNumber: number, prNodeId: string, - platformOptions: PlatformPrOptions | undefined, + platformPrOptions: PlatformPrOptions | undefined, ): Promise { - if (!platformOptions?.usePlatformAutomerge) { + if (!platformPrOptions?.usePlatformAutomerge) { return; } @@ -1718,7 +1718,7 @@ export async function createPr({ prBody: rawBody, labels, draftPR = false, - platformOptions, + platformPrOptions, milestone, }: CreatePRConfig): Promise { const body = sanitize(rawBody); @@ -1741,7 +1741,7 @@ export async function createPr({ options.token = config.forkToken; options.body.maintainer_can_modify = !config.forkOrg && - platformOptions?.forkModeDisallowMaintainerEdits !== true; + platformPrOptions?.forkModeDisallowMaintainerEdits !== true; } logger.debug({ title, head, base, draft: draftPR }, 'Creating PR'); const ghPr = ( @@ -1760,7 +1760,7 @@ export async function createPr({ await addLabels(number, labels); await tryAddMilestone(number, milestone); - await tryPrAutomerge(number, node_id, platformOptions); + await tryPrAutomerge(number, node_id, platformPrOptions); cachePr(result); return result; @@ -1824,13 +1824,13 @@ export async function updatePr({ export async function reattemptPlatformAutomerge({ number, - platformOptions, + platformPrOptions, }: ReattemptPlatformAutomergeConfig): Promise { try { const result = (await getPr(number))!; const { node_id } = result; - await tryPrAutomerge(number, node_id, platformOptions); + await tryPrAutomerge(number, node_id, platformPrOptions); logger.debug(`PR platform automerge re-attempted...prNo: ${number}`); } catch (err) { diff --git a/lib/modules/platform/gitlab/index.spec.ts b/lib/modules/platform/gitlab/index.spec.ts index f327ec9a5d4ec9..671e64080280d8 100644 --- a/lib/modules/platform/gitlab/index.spec.ts +++ b/lib/modules/platform/gitlab/index.spec.ts @@ -1884,7 +1884,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }), @@ -1928,7 +1928,7 @@ describe('modules/platform/gitlab/index', () => { targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }); @@ -1983,7 +1983,7 @@ describe('modules/platform/gitlab/index', () => { targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }); @@ -2037,7 +2037,7 @@ describe('modules/platform/gitlab/index', () => { targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }); @@ -2099,7 +2099,7 @@ describe('modules/platform/gitlab/index', () => { targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }); @@ -2212,7 +2212,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2257,7 +2257,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: false, gitLabIgnoreApprovals: true, }, @@ -2314,7 +2314,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2382,7 +2382,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2460,7 +2460,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2509,7 +2509,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2560,7 +2560,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, gitLabIgnoreApprovals: true, }, @@ -2595,7 +2595,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { autoApprove: true, }, }), @@ -2627,7 +2627,7 @@ describe('modules/platform/gitlab/index', () => { prTitle: 'some-title', prBody: 'the-body', labels: [], - platformOptions: { + platformPrOptions: { autoApprove: true, }, }), @@ -2917,7 +2917,7 @@ describe('modules/platform/gitlab/index', () => { number: 1, prTitle: 'title', prBody: 'body', - platformOptions: { + platformPrOptions: { autoApprove: true, }, }), @@ -2981,10 +2981,10 @@ describe('modules/platform/gitlab/index', () => { }); }); - describe('reattemptPlatformAutomerge(number, platformOptions)', () => { + describe('reattemptPlatformAutomerge(number, platformPrOptions)', () => { const pr = { number: 12345, - platformOptions: { + platformPrOptions: { usePlatformAutomerge: true, }, }; diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 4fb612ee4e3197..b6088632fc7518 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -646,14 +646,14 @@ async function ignoreApprovals(pr: number): Promise { async function tryPrAutomerge( pr: number, - platformOptions: PlatformPrOptions | undefined, + platformPrOptions: PlatformPrOptions | undefined, ): Promise { try { - if (platformOptions?.gitLabIgnoreApprovals) { + if (platformPrOptions?.gitLabIgnoreApprovals) { await ignoreApprovals(pr); } - if (platformOptions?.usePlatformAutomerge) { + if (platformPrOptions?.usePlatformAutomerge) { // https://docs.gitlab.com/ee/api/merge_requests.html#merge-status const desiredDetailedMergeStatus = [ 'mergeable', @@ -753,7 +753,7 @@ export async function createPr({ prBody: rawDescription, draftPR, labels, - platformOptions, + platformPrOptions, }: CreatePRConfig): Promise { let title = prTitle; if (draftPR) { @@ -783,11 +783,11 @@ export async function createPr({ config.prList.push(pr); } - if (platformOptions?.autoApprove) { + if (platformPrOptions?.autoApprove) { await approvePr(pr.iid); } - await tryPrAutomerge(pr.iid, platformOptions); + await tryPrAutomerge(pr.iid, platformPrOptions); return massagePr(pr); } @@ -821,7 +821,7 @@ export async function updatePr({ addLabels, removeLabels, state, - platformOptions, + platformPrOptions, targetBranch, }: UpdatePrConfig): Promise { let title = prTitle; @@ -856,16 +856,16 @@ export async function updatePr({ { body }, ); - if (platformOptions?.autoApprove) { + if (platformPrOptions?.autoApprove) { await approvePr(iid); } } export async function reattemptPlatformAutomerge({ number: iid, - platformOptions, + platformPrOptions, }: ReattemptPlatformAutomergeConfig): Promise { - await tryPrAutomerge(iid, platformOptions); + await tryPrAutomerge(iid, platformPrOptions); logger.debug(`PR platform automerge re-attempted...prNo: ${iid}`); } diff --git a/lib/modules/platform/types.ts b/lib/modules/platform/types.ts index e9f21232d71b4a..dc00ee88778111 100644 --- a/lib/modules/platform/types.ts +++ b/lib/modules/platform/types.ts @@ -112,13 +112,13 @@ export interface CreatePRConfig { prTitle: string; prBody: string; labels?: string[] | null; - platformOptions?: PlatformPrOptions; + platformPrOptions?: PlatformPrOptions; draftPR?: boolean; milestone?: number; } export interface UpdatePrConfig { number: number; - platformOptions?: PlatformPrOptions; + platformPrOptions?: PlatformPrOptions; prTitle: string; prBody?: string; state?: 'open' | 'closed'; @@ -148,7 +148,7 @@ export interface UpdatePrConfig { } export interface ReattemptPlatformAutomergeConfig { number: number; - platformOptions?: PlatformPrOptions; + platformPrOptions?: PlatformPrOptions; } export interface EnsureIssueConfig { title: string; diff --git a/lib/workers/repository/config-migration/pr/index.ts b/lib/workers/repository/config-migration/pr/index.ts index aaf28923789c15..53a3ccb57744cd 100644 --- a/lib/workers/repository/config-migration/pr/index.ts +++ b/lib/workers/repository/config-migration/pr/index.ts @@ -102,7 +102,7 @@ ${ prTitle, prBody, labels, - platformOptions: getPlatformPrOptions({ + platformPrOptions: getPlatformPrOptions({ ...config, automerge: false, }), diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 5ce7fb3bbe3122..3150d381324d9a 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -187,7 +187,7 @@ If you need any further assistance then you can also [request help here](${ prTitle, prBody, labels, - platformOptions: getPlatformPrOptions({ + platformPrOptions: getPlatformPrOptions({ ...config, automerge: false, }), diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index c241925cdb8cc4..e9d9b71ce9766a 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -594,14 +594,14 @@ export async function processBranch( } if (branchPr) { - const platformOptions = getPlatformPrOptions(config); + const platformPrOptions = getPlatformPrOptions(config); if ( - platformOptions.usePlatformAutomerge && + platformPrOptions.usePlatformAutomerge && platform.reattemptPlatformAutomerge ) { await platform.reattemptPlatformAutomerge({ number: branchPr.number, - platformOptions, + platformPrOptions, }); } // istanbul ignore if diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts index e4e11d7738a4ce..100626dd6c513b 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -386,7 +386,7 @@ export async function ensurePr( number: existingPr.number, prTitle, prBody, - platformOptions: getPlatformPrOptions(config), + platformPrOptions: getPlatformPrOptions(config), }; // PR must need updating if (existingPr?.targetBranch !== config.baseBranch) { @@ -490,7 +490,7 @@ export async function ensurePr( prTitle, prBody, labels: prepareLabels(config), - platformOptions: getPlatformPrOptions(config), + platformPrOptions: getPlatformPrOptions(config), draftPR: !!config.draftPR, milestone: config.milestone, });