From 9896f5e562d5da0dd0c435a6c5375021f528e5ba Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 9 Sep 2020 11:07:38 +0200 Subject: [PATCH] refactor: handle undefined platformOptions (#7227) --- lib/platform/azure/index.ts | 6 +++--- lib/platform/bitbucket-server/index.ts | 4 ++-- lib/platform/bitbucket/index.ts | 4 ++-- lib/platform/github/index.ts | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 464b209a66..eb213d3c36 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -318,7 +318,7 @@ export async function createPr({ prBody: body, labels, draftPR = false, - platformOptions = {}, + platformOptions, }: CreatePRConfig): Promise<Pr> { const sourceRefName = getNewBranchName(branchName); const targetRefName = getNewBranchName(targetBranch); @@ -326,7 +326,7 @@ export async function createPr({ const azureApiGit = await azureApi.gitApi(); const workItemRefs = [ { - id: platformOptions.azureWorkItemId?.toString(), + id: platformOptions?.azureWorkItemId?.toString(), }, ]; let pr: GitPullRequest = await azureApiGit.createPullRequest( @@ -340,7 +340,7 @@ export async function createPr({ }, config.repoId ); - if (platformOptions.azureAutoComplete) { + if (platformOptions?.azureAutoComplete) { pr = await azureApiGit.updatePullRequest( { autoCompleteSetBy: { diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index b75777a3c5..7f7c0dde1c 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -769,7 +769,7 @@ export async function createPr({ targetBranch, prTitle: title, prBody: rawDescription, - platformOptions = {}, + platformOptions, }: CreatePRConfig): Promise<Pr> { const description = sanitize(rawDescription); logger.debug(`createPr(${branchName}, title=${title})`); @@ -777,7 +777,7 @@ export async function createPr({ let reviewers: BbsRestUserRef[] = []; /* istanbul ignore else */ - if (platformOptions.bbUseDefaultReviewers) { + if (platformOptions?.bbUseDefaultReviewers) { logger.debug(`fetching default reviewers`); const { id } = ( await bitbucketServerHttp.getJson<{ id: number }>( diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 419c0eb34c..1c048baccd 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -629,7 +629,7 @@ export async function createPr({ targetBranch, prTitle: title, prBody: description, - platformOptions = {}, + platformOptions, }: CreatePRConfig): Promise<Pr> { // labels is not supported in Bitbucket: https://bitbucket.org/site/master/issues/11976/ability-to-add-labels-to-pull-requests-bb @@ -639,7 +639,7 @@ export async function createPr({ let reviewers: { uuid: { raw: string } }[] = []; - if (platformOptions.bbUseDefaultReviewers) { + if (platformOptions?.bbUseDefaultReviewers) { const reviewersResponse = ( await bitbucketHttp.getJson<utils.PagedResult<Reviewer>>( `/2.0/repositories/${config.repository}/default-reviewers` diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 7dc6929ffd..6323c563ee 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -1373,7 +1373,6 @@ export async function createPr({ prTitle: title, prBody: rawBody, labels, - platformOptions = {}, draftPR = false, }: CreatePRConfig): Promise<Pr> { const body = sanitize(rawBody); -- GitLab