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

refactor: rename platformOptions -> platformPrOptions #30173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions lib/modules/platform/azure/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
[
[
{
Expand All @@ -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`] = `
[
[
{
Expand All @@ -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`] = `
[
[
{
Expand All @@ -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`] = `
[
[
{
Expand Down
16 changes: 8 additions & 8 deletions lib/modules/platform/azure/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -996,7 +996,7 @@ describe('modules/platform/azure/index', () => {
prTitle: 'The Title',
prBody: 'Hello world',
labels: ['deps', 'renovate'],
platformOptions: {
platformPrOptions: {
automergeStrategy: 'auto',
usePlatformAutomerge: true,
},
Expand All @@ -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,
},
Expand Down Expand Up @@ -1061,7 +1061,7 @@ describe('modules/platform/azure/index', () => {
prTitle: 'The Title',
prBody: 'Hello world',
labels: ['deps', 'renovate'],
platformOptions: {
platformPrOptions: {
automergeStrategy,
usePlatformAutomerge: true,
},
Expand Down Expand Up @@ -1113,7 +1113,7 @@ describe('modules/platform/azure/index', () => {
prTitle: 'The Title',
prBody: 'Hello world',
labels: ['deps', 'renovate'],
platformOptions: {
platformPrOptions: {
automergeStrategy,
usePlatformAutomerge: true,
},
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions lib/modules/platform/azure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,15 @@ export async function createPr({
prBody: body,
labels,
draftPR = false,
platformOptions,
platformPrOptions,
}: CreatePRConfig): Promise<Pr> {
const sourceRefName = getNewBranchName(sourceBranch);
const targetRefName = getNewBranchName(targetBranch);
const description = max4000Chars(sanitize(body));
const azureApiGit = await azureApi.gitApi();
const workItemRefs = [
{
id: platformOptions?.azureWorkItemId?.toString(),
id: platformPrOptions?.azureWorkItemId?.toString(),
},
];
let pr: GitPullRequest = await azureApiGit.createPullRequest(
Expand All @@ -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: {
Expand All @@ -509,7 +509,7 @@ export async function createPr({
pr.pullRequestId!,
);
}
if (platformOptions?.autoApprove) {
if (platformPrOptions?.autoApprove) {
await azureApiGit.createPullRequestReviewer(
{
reviewerUrl: pr.createdBy!.url,
Expand Down Expand Up @@ -543,7 +543,7 @@ export async function updatePr({
prTitle: title,
prBody: body,
state,
platformOptions,
platformPrOptions,
targetBranch,
}: UpdatePrConfig): Promise<void> {
logger.debug(`updatePr(${prNo}, ${title}, body)`);
Expand Down Expand Up @@ -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(
{
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/bitbucket-server/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ describe('modules/platform/bitbucket-server/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand All @@ -1514,7 +1514,7 @@ describe('modules/platform/bitbucket-server/index', () => {
prTitle: 'title',
prBody: 'body',
labels: null,
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,15 +865,14 @@ export async function createPr({
targetBranch,
prTitle: title,
prBody: rawDescription,
platformOptions,
platformPrOptions,
}: CreatePRConfig): Promise<Pr> {
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 }>(
Expand Down
14 changes: 7 additions & 7 deletions lib/modules/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand Down Expand Up @@ -1188,7 +1188,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand Down Expand Up @@ -1251,7 +1251,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand Down Expand Up @@ -1297,7 +1297,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
}),
Expand Down Expand Up @@ -1352,7 +1352,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
});
Expand Down Expand Up @@ -1391,7 +1391,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
}),
Expand Down Expand Up @@ -1430,7 +1430,7 @@ describe('modules/platform/bitbucket/index', () => {
targetBranch: 'master',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
bbUseDefaultReviewers: true,
},
}),
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ export async function createPr({
targetBranch,
prTitle: title,
prBody: description,
platformOptions,
platformPrOptions,
}: CreatePRConfig): Promise<Pr> {
// labels is not supported in Bitbucket: https://bitbucket.org/site/master/issues/11976/ability-to-add-labels-to-pull-requests-bb

Expand All @@ -877,7 +877,7 @@ export async function createPr({

let reviewers: Account[] = [];

if (platformOptions?.bbUseDefaultReviewers) {
if (platformPrOptions?.bbUseDefaultReviewers) {
const reviewersResponse = (
await bitbucketHttp.getJson<PagedResult<EffectiveReviewer>>(
`/2.0/repositories/${config.repository}/effective-default-reviewers`,
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/platform/gerrit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('modules/platform/gerrit/index', () => {
await gerrit.updatePr({
number: 123456,
prTitle: 'subject',
platformOptions: {
platformPrOptions: {
autoApprove: true,
},
});
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('modules/platform/gerrit/index', () => {
targetBranch: 'target',
prTitle: 'title',
prBody: 'body',
platformOptions: {
platformPrOptions: {
autoApprove: false,
},
});
Expand All @@ -362,7 +362,7 @@ describe('modules/platform/gerrit/index', () => {
targetBranch: 'target',
prTitle: change.subject,
prBody: 'body',
platformOptions: {
platformPrOptions: {
autoApprove: true,
},
});
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/gerrit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export async function updatePr(prConfig: UpdatePrConfig): Promise<void> {
TAG_PULL_REQUEST_BODY,
);
}
if (prConfig.platformOptions?.autoApprove) {
if (prConfig.platformPrOptions?.autoApprove) {
await client.approveChange(prConfig.number);
}
if (prConfig.state && prConfig.state === 'closed') {
Expand Down Expand Up @@ -211,7 +211,7 @@ export async function createPr(prConfig: CreatePRConfig): Promise<Pr | null> {
prConfig.prBody,
TAG_PULL_REQUEST_BODY,
);
if (prConfig.platformOptions?.autoApprove) {
if (prConfig.platformPrOptions?.autoApprove) {
await client.approveChange(pr._number);
}
return getPr(pr._number);
Expand Down
14 changes: 7 additions & 7 deletions lib/modules/platform/gitea/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -1763,7 +1763,7 @@ describe('modules/platform/gitea/index', () => {
targetBranch: 'master',
prTitle: mockNewPR.title,
prBody: mockNewPR.body,
platformOptions: {
platformPrOptions: {
automergeStrategy: 'auto',
usePlatformAutomerge: true,
},
Expand Down Expand Up @@ -1802,7 +1802,7 @@ describe('modules/platform/gitea/index', () => {
targetBranch: 'master',
prTitle: mockNewPR.title,
prBody: mockNewPR.body,
platformOptions: {
platformPrOptions: {
automergeStrategy,
usePlatformAutomerge: true,
},
Expand Down
Loading