renovate 39.7.6 → 39.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -483,6 +483,7 @@
483
483
  "shopify-app-bridge": "https://github.com/Shopify/app-bridge",
484
484
  "sitecore-jss": "https://github.com/Sitecore/jss",
485
485
  "skiasharp": "https://github.com/mono/SkiaSharp",
486
+ "slack-net": "https://github.com/soxtoby/SlackNet",
486
487
  "slf4j": "https://github.com/qos-ch/slf4j",
487
488
  "spectre-console": "https://github.com/spectreconsole/spectre.console",
488
489
  "springfox": "https://github.com/springfox/springfox",
@@ -717,13 +717,27 @@ async function updatePr({ number: prNo, prTitle: title, prBody: rawDescription,
717
717
  ['open']: 'OPEN',
718
718
  ['closed']: 'DECLINED',
719
719
  }[state];
720
+ let finalState = currentState === 'OPEN' ? 'open' : 'closed';
720
721
  if (newState &&
721
722
  ['OPEN', 'DECLINED'].includes(currentState) &&
722
723
  currentState !== newState) {
723
724
  const command = state === 'open' ? 'reopen' : 'decline';
724
725
  const { body: updatedStatePr } = await bitbucketServerHttp.postJson(`./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${pr.number}/${command}?version=${updatedPr.version}`);
726
+ finalState = state;
725
727
  updatePrVersion(pr.number, updatedStatePr.version);
726
728
  }
729
+ if (config.prList) {
730
+ const bbsPr = utils.prInfo(updatedPr);
731
+ const existingIndex = config.prList.findIndex((item) => item.number === prNo);
732
+ // istanbul ignore if: should never happen
733
+ if (existingIndex === -1) {
734
+ logger_1.logger.warn({ pr: bbsPr }, 'Possible error: Updated PR was not found in the PRs that were returned from getPrList().');
735
+ config.prList.push({ ...bbsPr, state: finalState });
736
+ }
737
+ else {
738
+ config.prList[existingIndex] = { ...bbsPr, state: finalState };
739
+ }
740
+ }
727
741
  }
728
742
  catch (err) {
729
743
  logger_1.logger.debug({ err, prNo }, `Failed to update PR`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/modules/platform/bitbucket-server/index.ts"],"names":[],"mappings":";;;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ACxC,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { setTimeout } from 'timers/promises';\nimport semver from 'semver';\nimport type { PartialDeep } from 'type-fest';\nimport {\n REPOSITORY_CHANGED,\n REPOSITORY_EMPTY,\n REPOSITORY_NOT_FOUND,\n} from '../../../constants/error-messages';\nimport { logger } from '../../../logger';\nimport type { BranchStatus } from '../../../types';\nimport type { FileData } from '../../../types/platform/bitbucket-server';\nimport { parseJson } from '../../../util/common';\nimport * as git from '../../../util/git';\nimport { deleteBranch } from '../../../util/git';\nimport * as hostRules from '../../../util/host-rules';\nimport {\n BitbucketServerHttp,\n setBaseUrl,\n} from '../../../util/http/bitbucket-server';\nimport type { HttpOptions, HttpResponse } from '../../../util/http/types';\nimport { newlineRegex, regEx } from '../../../util/regex';\nimport { sanitize } from '../../../util/sanitize';\nimport { ensureTrailingSlash, getQueryString } from '../../../util/url';\nimport type {\n BranchStatusConfig,\n CreatePRConfig,\n EnsureCommentConfig,\n EnsureCommentRemovalConfig,\n EnsureIssueConfig,\n EnsureIssueResult,\n FindPRConfig,\n Issue,\n MergePRConfig,\n PlatformParams,\n PlatformResult,\n Pr,\n RepoParams,\n RepoResult,\n UpdatePrConfig,\n} from '../types';\nimport { getNewBranchName, repoFingerprint } from '../util';\nimport { smartTruncate } from '../utils/pr-body';\nimport { UserSchema } from './schema';\nimport type {\n BbsConfig,\n BbsPr,\n BbsRestBranch,\n BbsRestPr,\n BbsRestRepo,\n BbsRestUserRef,\n} from './types';\nimport * as utils from './utils';\nimport { getExtraCloneOpts } from './utils';\n\n/*\n * Version: 5.3 (EOL Date: 15 Aug 2019)\n * See following docs for api information:\n * https://docs.atlassian.com/bitbucket-server/rest/5.3.0/bitbucket-rest.html\n * https://docs.atlassian.com/bitbucket-server/rest/5.3.0/bitbucket-build-rest.html\n *\n * See following page for uptodate supported versions\n * https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html#AtlassianSupportEndofLifePolicy-BitbucketServer\n */\n\nexport const id = 'bitbucket-server';\n\nlet config: BbsConfig = {} as any;\n\nconst bitbucketServerHttp = new BitbucketServerHttp();\n\nconst defaults: {\n endpoint?: string;\n hostType: string;\n version: string;\n} = {\n hostType: 'bitbucket-server',\n version: '0.0.0',\n};\n\n/* istanbul ignore next */\nfunction updatePrVersion(pr: number, version: number): number {\n const res = Math.max(config.prVersions.get(pr) ?? 0, version);\n config.prVersions.set(pr, res);\n return res;\n}\n\nexport async function initPlatform({\n endpoint,\n token,\n username,\n password,\n gitAuthor,\n}: PlatformParams): Promise<PlatformResult> {\n if (!endpoint) {\n throw new Error('Init: You must configure a Bitbucket Server endpoint');\n }\n if (!(username && password) && !token) {\n throw new Error(\n 'Init: You must either configure a Bitbucket Server username/password or a HTTP access token',\n );\n } else if (password && token) {\n throw new Error(\n 'Init: You must configure either a Bitbucket Server password or a HTTP access token, not both',\n );\n }\n // TODO: Add a connection check that endpoint/username/password combination are valid (#9595)\n defaults.endpoint = ensureTrailingSlash(endpoint);\n setBaseUrl(defaults.endpoint);\n const platformConfig: PlatformResult = {\n endpoint: defaults.endpoint,\n };\n try {\n let bitbucketServerVersion: string;\n // istanbul ignore if: experimental feature\n if (process.env.RENOVATE_X_PLATFORM_VERSION) {\n bitbucketServerVersion = process.env.RENOVATE_X_PLATFORM_VERSION;\n } else {\n const { version } = (\n await bitbucketServerHttp.getJson<{ version: string }>(\n `./rest/api/1.0/application-properties`,\n )\n ).body;\n bitbucketServerVersion = version;\n logger.debug('Bitbucket Server version is: ' + bitbucketServerVersion);\n }\n\n if (semver.valid(bitbucketServerVersion)) {\n defaults.version = bitbucketServerVersion;\n }\n } catch (err) {\n logger.debug(\n { err },\n 'Error authenticating with Bitbucket. Check that your token includes \"api\" permissions',\n );\n }\n\n if (!gitAuthor && username) {\n logger.debug(`Attempting to confirm gitAuthor from username`);\n const options: HttpOptions = {\n memCache: false,\n };\n\n if (token) {\n options.token = token;\n } else {\n options.username = username;\n options.password = password;\n }\n\n try {\n const { displayName, emailAddress } = (\n await bitbucketServerHttp.getJson(\n `./rest/api/1.0/users/${username}`,\n options,\n UserSchema,\n )\n ).body;\n\n platformConfig.gitAuthor = `${displayName} <${emailAddress}>`;\n\n logger.debug(`Detected gitAuthor: ${platformConfig.gitAuthor}`);\n } catch (err) {\n logger.debug(\n { err },\n 'Failed to get user info, fallback gitAuthor will be used',\n );\n }\n }\n\n return platformConfig;\n}\n\n// Get all repositories that the user has access to\nexport async function getRepos(): Promise<string[]> {\n logger.debug('Autodiscovering Bitbucket Server repositories');\n try {\n const repos = await utils.accumulateValues(\n `./rest/api/1.0/repos?permission=REPO_WRITE&state=AVAILABLE`,\n );\n const result = repos.map(\n (r: { project: { key: string }; slug: string }) =>\n `${r.project.key}/${r.slug}`,\n );\n logger.debug({ result }, 'result of getRepos()');\n return result;\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, `bitbucket getRepos error`);\n throw err;\n }\n}\n\nexport async function getRawFile(\n fileName: string,\n repoName?: string,\n branchOrTag?: string,\n): Promise<string | null> {\n const repo = repoName ?? config.repository;\n const [project, slug] = repo.split('/');\n const fileUrl =\n `./rest/api/1.0/projects/${project}/repos/${slug}/browse/${fileName}?limit=20000` +\n (branchOrTag ? '&at=' + branchOrTag : '');\n const res = await bitbucketServerHttp.getJson<FileData>(fileUrl);\n const { isLastPage, lines, size } = res.body;\n if (isLastPage) {\n return lines.map(({ text }) => text).join('\\n');\n }\n const msg = `The file is too big (${size}B)`;\n logger.warn({ size }, msg);\n throw new Error(msg);\n}\n\nexport async function getJsonFile(\n fileName: string,\n repoName?: string,\n branchOrTag?: string,\n): Promise<any> {\n // TODO #22198\n const raw = await getRawFile(fileName, repoName, branchOrTag);\n return parseJson(raw, fileName);\n}\n\n// Initialize Bitbucket Server by getting base branch\nexport async function initRepo({\n repository,\n cloneSubmodules,\n ignorePrAuthor,\n gitUrl,\n}: RepoParams): Promise<RepoResult> {\n logger.debug(`initRepo(\"${JSON.stringify({ repository }, null, 2)}\")`);\n const opts = hostRules.find({\n hostType: defaults.hostType,\n url: defaults.endpoint,\n });\n\n const [projectKey, repositorySlug] = repository.split('/');\n\n config = {\n projectKey,\n repositorySlug,\n repository,\n prVersions: new Map<number, number>(),\n username: opts.username,\n ignorePrAuthor,\n } as any;\n\n try {\n const info = (\n await bitbucketServerHttp.getJson<BbsRestRepo>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}`,\n )\n ).body;\n config.owner = info.project.key;\n logger.debug(`${repository} owner = ${config.owner}`);\n const branchRes = await bitbucketServerHttp.getJson<BbsRestBranch>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/branches/default`,\n );\n\n // 204 means empty, 404 means repo not found or missing default branch. repo must exist here.\n if ([204, 404].includes(branchRes.statusCode)) {\n throw new Error(REPOSITORY_EMPTY);\n }\n\n const url = utils.getRepoGitUrl(\n config.repositorySlug,\n // TODO #22198\n defaults.endpoint!,\n gitUrl,\n info,\n opts,\n );\n\n await git.initRepo({\n ...config,\n url,\n extraCloneOpts: getExtraCloneOpts(opts),\n cloneSubmodules,\n fullClone: semver.lte(defaults.version, '8.0.0'),\n });\n\n config.mergeMethod = 'merge';\n const repoConfig: RepoResult = {\n defaultBranch: branchRes.body.displayId,\n isFork: !!info.origin,\n repoFingerprint: repoFingerprint(info.id, defaults.endpoint),\n };\n\n return repoConfig;\n } catch (err) /* istanbul ignore next */ {\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n }\n if (err.message === REPOSITORY_EMPTY) {\n throw err;\n }\n\n logger.debug({ err }, 'Unknown Bitbucket initRepo error');\n throw err;\n }\n}\n\nexport async function getBranchForceRebase(\n _branchName: string,\n): Promise<boolean> {\n // https://docs.atlassian.com/bitbucket-server/rest/7.0.1/bitbucket-rest.html#idp342\n const res = await bitbucketServerHttp.getJson<{\n mergeConfig: { defaultStrategy: { id: string } };\n }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/settings/pull-requests`,\n );\n\n // If the default merge strategy contains `ff-only` the PR can only be merged\n // if it is up to date with the base branch.\n // The current options for id are:\n // no-ff, ff, ff-only, rebase-no-ff, rebase-ff-only, squash, squash-ff-only\n return Boolean(\n res.body?.mergeConfig?.defaultStrategy?.id.includes('ff-only'),\n );\n}\n// Gets details for a PR\nexport async function getPr(\n prNo: number,\n refreshCache?: boolean,\n): Promise<BbsPr | null> {\n logger.debug(`getPr(${prNo})`);\n if (!prNo) {\n return null;\n }\n\n const res = await bitbucketServerHttp.getJson<BbsRestPr>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n { memCache: !refreshCache },\n );\n\n const pr: BbsPr = {\n ...utils.prInfo(res.body),\n reviewers: res.body.reviewers.map((r) => r.user.name),\n };\n // TODO #22198\n pr.version = updatePrVersion(pr.number, pr.version!);\n\n return pr;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nfunction matchesState(state: string, desiredState: string): boolean {\n if (desiredState === 'all') {\n return true;\n }\n if (desiredState.startsWith('!')) {\n return state !== desiredState.substring(1);\n }\n return state === desiredState;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nconst isRelevantPr =\n (branchName: string, prTitle: string | null | undefined, state: string) =>\n (p: Pr): boolean =>\n p.sourceBranch === branchName &&\n (!prTitle || p.title.toUpperCase() === prTitle.toUpperCase()) &&\n matchesState(p.state, state);\n\n// TODO: coverage (#9624)\nexport async function getPrList(refreshCache?: boolean): Promise<Pr[]> {\n logger.debug(`getPrList()`);\n // istanbul ignore next\n if (!config.prList || refreshCache) {\n const searchParams: Record<string, string> = {\n state: 'ALL',\n };\n if (!config.ignorePrAuthor && config.username !== undefined) {\n searchParams['role.1'] = 'AUTHOR';\n searchParams['username.1'] = config.username;\n }\n const query = getQueryString(searchParams);\n const values = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?${query}`,\n );\n\n config.prList = values.map(utils.prInfo);\n logger.debug(`Retrieved Pull Requests, count: ${config.prList.length}`);\n } else {\n logger.debug('returning cached PR list');\n }\n return config.prList;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nexport async function findPr({\n branchName,\n prTitle,\n state = 'all',\n refreshCache,\n includeOtherAuthors,\n}: FindPRConfig): Promise<Pr | null> {\n logger.debug(`findPr(${branchName}, \"${prTitle!}\", \"${state}\")`);\n\n if (includeOtherAuthors) {\n // PR might have been created by anyone, so don't use the cached Renovate PR list\n const searchParams: Record<string, string> = {\n state: 'OPEN',\n };\n searchParams['direction'] = 'outgoing';\n searchParams['at'] = `refs/heads/${branchName}`;\n\n const query = getQueryString(searchParams);\n const prs = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?${query}`,\n 'get',\n {},\n 1, // only fetch the latest pr\n );\n\n if (!prs.length) {\n logger.debug(`No PR found for branch ${branchName}`);\n return null;\n }\n\n return utils.prInfo(prs[0]);\n }\n\n const prList = await getPrList(refreshCache);\n const pr = prList.find(isRelevantPr(branchName, prTitle, state));\n if (pr) {\n logger.debug(`Found PR #${pr.number}`);\n } else {\n logger.debug(`Renovate did not find a PR for branch #${branchName}`);\n }\n return pr ?? null;\n}\n\n// Returns the Pull Request for a branch. Null if not exists.\nexport async function getBranchPr(branchName: string): Promise<BbsPr | null> {\n logger.debug(`getBranchPr(${branchName})`);\n const existingPr = await findPr({\n branchName,\n state: 'open',\n });\n return existingPr ? getPr(existingPr.number) : null;\n}\n\n// istanbul ignore next\nexport async function refreshPr(number: number): Promise<void> {\n // wait for pr change propagation\n await setTimeout(1000);\n // refresh cache\n await getPr(number, true);\n}\n\nasync function getStatus(\n branchName: string,\n memCache = true,\n): Promise<utils.BitbucketCommitStatus> {\n const branchCommit = git.getBranchCommit(branchName);\n\n return (\n await bitbucketServerHttp.getJson<utils.BitbucketCommitStatus>(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/stats/${branchCommit!}`,\n { memCache },\n )\n ).body;\n}\n\n// Returns the combined status for a branch.\n// umbrella for status checks\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-build-rest.html#idp2\nexport async function getBranchStatus(\n branchName: string,\n): Promise<BranchStatus> {\n logger.debug(`getBranchStatus(${branchName})`);\n\n if (!git.branchExists(branchName)) {\n logger.debug('Branch does not exist - cannot fetch status');\n throw new Error(REPOSITORY_CHANGED);\n }\n\n try {\n const commitStatus = await getStatus(branchName);\n\n logger.debug({ commitStatus }, 'branch status check result');\n\n if (commitStatus.failed > 0) {\n return 'red';\n }\n if (commitStatus.inProgress > 0) {\n return 'yellow';\n }\n return commitStatus.successful > 0 ? 'green' : 'yellow';\n } catch (err) {\n logger.warn({ err }, `Failed to get branch status`);\n return 'red';\n }\n}\n\nfunction getStatusCheck(\n branchName: string,\n memCache = true,\n): Promise<utils.BitbucketStatus[]> {\n const branchCommit = git.getBranchCommit(branchName);\n\n return utils.accumulateValues(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/${branchCommit!}`,\n 'get',\n { memCache },\n );\n}\n\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-build-rest.html#idp2\nexport async function getBranchStatusCheck(\n branchName: string,\n context: string,\n): Promise<BranchStatus | null> {\n logger.debug(`getBranchStatusCheck(${branchName}, context=${context})`);\n\n try {\n const states = await getStatusCheck(branchName);\n\n for (const state of states) {\n if (state.key === context) {\n switch (state.state) {\n case 'SUCCESSFUL':\n return 'green';\n case 'INPROGRESS':\n return 'yellow';\n case 'FAILED':\n default:\n return 'red';\n }\n }\n }\n } catch (err) {\n logger.warn({ err }, `Failed to check branch status`);\n }\n return null;\n}\n\nexport async function setBranchStatus({\n branchName,\n context,\n description,\n state,\n url: targetUrl,\n}: BranchStatusConfig): Promise<void> {\n logger.debug(`setBranchStatus(${branchName})`);\n\n const existingStatus = await getBranchStatusCheck(branchName, context);\n if (existingStatus === state) {\n return;\n }\n logger.debug({ branch: branchName, context, state }, 'Setting branch status');\n\n const branchCommit = git.getBranchCommit(branchName);\n\n try {\n const body: any = {\n key: context,\n description,\n url: targetUrl ?? 'https://renovatebot.com',\n };\n\n switch (state) {\n case 'green':\n body.state = 'SUCCESSFUL';\n break;\n case 'yellow':\n body.state = 'INPROGRESS';\n break;\n case 'red':\n default:\n body.state = 'FAILED';\n break;\n }\n\n await bitbucketServerHttp.postJson(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/${branchCommit!}`,\n { body },\n );\n\n // update status cache\n await getStatus(branchName, false);\n await getStatusCheck(branchName, false);\n } catch (err) {\n logger.warn({ err }, `Failed to set branch status`);\n }\n}\n\n// Issue\n\n/* istanbul ignore next */\nexport function findIssue(title: string): Promise<Issue | null> {\n logger.debug(`findIssue(${title})`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve(null);\n}\n\n/* istanbul ignore next */\nexport function ensureIssue({\n title,\n}: EnsureIssueConfig): Promise<EnsureIssueResult | null> {\n logger.warn({ title }, 'Cannot ensure issue');\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve(null);\n}\n\n/* istanbul ignore next */\nexport function getIssueList(): Promise<Issue[]> {\n logger.debug(`getIssueList()`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve([]);\n}\n\n/* istanbul ignore next */\nexport function ensureIssueClosing(title: string): Promise<void> {\n logger.debug(`ensureIssueClosing(${title})`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\nexport function addAssignees(iid: number, assignees: string[]): Promise<void> {\n logger.debug(`addAssignees(${iid}, [${assignees.join(', ')}])`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\nexport async function addReviewers(\n prNo: number,\n reviewers: string[],\n): Promise<void> {\n logger.debug(`Adding reviewers '${reviewers.join(', ')}' to #${prNo}`);\n\n await retry(updatePRAndAddReviewers, [prNo, reviewers], 3, [\n REPOSITORY_CHANGED,\n ]);\n}\n\nasync function updatePRAndAddReviewers(\n prNo: number,\n reviewers: string[],\n): Promise<void> {\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw new Error(REPOSITORY_NOT_FOUND);\n }\n\n // TODO: can `reviewers` be undefined? (#22198)\n const reviewersSet = new Set([...pr.reviewers!, ...reviewers]);\n\n await bitbucketServerHttp.putJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n {\n body: {\n title: pr.title,\n version: pr.version,\n reviewers: Array.from(reviewersSet).map((name) => ({\n user: { name },\n })),\n },\n },\n );\n await getPr(prNo, true);\n } catch (err) {\n logger.warn({ err, reviewers, prNo }, `Failed to add reviewers`);\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (\n err.statusCode === 409 &&\n !utils.isInvalidReviewersResponse(err)\n ) {\n logger.debug(\n '409 response to adding reviewers - has repository changed?',\n );\n throw new Error(REPOSITORY_CHANGED);\n } else {\n throw err;\n }\n }\n}\n\nasync function retry<T extends (...arg0: any[]) => Promise<any>>(\n fn: T,\n args: Parameters<T>,\n maxTries: number,\n retryErrorMessages: string[],\n): Promise<Awaited<ReturnType<T>>> {\n const maxAttempts = Math.max(maxTries, 1);\n let lastError: Error | undefined;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn(...args);\n } catch (e) {\n lastError = e;\n if (\n retryErrorMessages.length !== 0 &&\n !retryErrorMessages.includes(e.message)\n ) {\n logger.debug(`Error not marked for retry`);\n throw e;\n }\n }\n }\n\n logger.debug(`All ${maxAttempts} retry attempts exhausted`);\n // Can't be `undefined` here.\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw lastError;\n}\n\nexport function deleteLabel(issueNo: number, label: string): Promise<void> {\n logger.debug(`deleteLabel(${issueNo}, ${label})`);\n // Only used for the \"request Renovate to rebase a PR using a label\" feature\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\ntype Comment = { text: string; id: number };\n\nasync function getComments(prNo: number): Promise<Comment[]> {\n // GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities\n let comments = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/activities`,\n );\n\n comments = comments\n .filter(\n (a: { action: string; commentAction: string }) =>\n a.action === 'COMMENTED' && a.commentAction === 'ADDED',\n )\n .map((a: { comment: Comment }) => a.comment);\n\n logger.debug(`Found ${comments.length} comments`);\n\n return comments;\n}\n\nasync function addComment(prNo: number, text: string): Promise<void> {\n // POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments\n await bitbucketServerHttp.postJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments`,\n {\n body: { text },\n },\n );\n}\n\nasync function getCommentVersion(\n prNo: number,\n commentId: number,\n): Promise<number> {\n // GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n const { version } = (\n await bitbucketServerHttp.getJson<{ version: number }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}`,\n )\n ).body;\n\n return version;\n}\n\nasync function editComment(\n prNo: number,\n commentId: number,\n text: string,\n): Promise<void> {\n const version = await getCommentVersion(prNo, commentId);\n\n // PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n await bitbucketServerHttp.putJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}`,\n {\n body: { text, version },\n },\n );\n}\n\nasync function deleteComment(prNo: number, commentId: number): Promise<void> {\n const version = await getCommentVersion(prNo, commentId);\n\n // DELETE /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n await bitbucketServerHttp.deleteJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}?version=${version}`,\n );\n}\n\nexport async function ensureComment({\n number,\n topic,\n content,\n}: EnsureCommentConfig): Promise<boolean> {\n const sanitizedContent = sanitize(content);\n try {\n const comments = await getComments(number);\n let body: string;\n let commentId: number | undefined;\n let commentNeedsUpdating: boolean | undefined;\n if (topic) {\n logger.debug(`Ensuring comment \"${topic}\" in #${number}`);\n body = `### ${topic}\\n\\n${sanitizedContent}`;\n comments.forEach((comment) => {\n if (comment.text.startsWith(`### ${topic}\\n\\n`)) {\n commentId = comment.id;\n commentNeedsUpdating = comment.text !== body;\n }\n });\n } else {\n logger.debug(`Ensuring content-only comment in #${number}`);\n body = `${sanitizedContent}`;\n comments.forEach((comment) => {\n if (comment.text === body) {\n commentId = comment.id;\n commentNeedsUpdating = false;\n }\n });\n }\n if (!commentId) {\n await addComment(number, body);\n logger.info(\n { repository: config.repository, prNo: number, topic },\n 'Comment added',\n );\n } else if (commentNeedsUpdating) {\n await editComment(number, commentId, body);\n logger.debug(\n { repository: config.repository, prNo: number },\n 'Comment updated',\n );\n } else {\n logger.debug('Comment is already update-to-date');\n }\n return true;\n } catch (err) /* istanbul ignore next */ {\n logger.warn({ err }, 'Error ensuring comment');\n return false;\n }\n}\n\nexport async function ensureCommentRemoval(\n deleteConfig: EnsureCommentRemovalConfig,\n): Promise<void> {\n try {\n const { number: prNo } = deleteConfig;\n const key =\n deleteConfig.type === 'by-topic'\n ? deleteConfig.topic\n : deleteConfig.content;\n logger.debug(`Ensuring comment \"${key}\" in #${prNo} is removed`);\n const comments = await getComments(prNo);\n\n let commentId: number | null | undefined = null;\n if (deleteConfig.type === 'by-topic') {\n const byTopic = (comment: Comment): boolean =>\n comment.text.startsWith(`### ${deleteConfig.topic}\\n\\n`);\n commentId = comments.find(byTopic)?.id;\n } else if (deleteConfig.type === 'by-content') {\n const byContent = (comment: Comment): boolean =>\n comment.text.trim() === deleteConfig.content;\n commentId = comments.find(byContent)?.id;\n }\n\n if (commentId) {\n await deleteComment(prNo, commentId);\n }\n } catch (err) /* istanbul ignore next */ {\n logger.warn({ err }, 'Error ensuring comment removal');\n }\n}\n\n// Pull Request\n\nconst escapeHash = (input: string): string =>\n input?.replace(regEx(/#/g), '%23');\n\nexport async function createPr({\n sourceBranch,\n targetBranch,\n prTitle: title,\n prBody: rawDescription,\n platformPrOptions,\n}: CreatePRConfig): Promise<Pr> {\n const description = sanitize(rawDescription);\n logger.debug(`createPr(${sourceBranch}, title=${title})`);\n const base = targetBranch;\n let reviewers: BbsRestUserRef[] = [];\n\n if (platformPrOptions?.bbUseDefaultReviewers) {\n logger.debug(`fetching default reviewers`);\n const { id } = (\n await bitbucketServerHttp.getJson<{ id: number }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}`,\n )\n ).body;\n\n const defReviewers = (\n await bitbucketServerHttp.getJson<{ name: string }[]>(\n `./rest/default-reviewers/1.0/projects/${config.projectKey}/repos/${\n config.repositorySlug\n }/reviewers?sourceRefId=refs/heads/${escapeHash(\n sourceBranch,\n )}&targetRefId=refs/heads/${base}&sourceRepoId=${id}&targetRepoId=${id}`,\n )\n ).body;\n\n reviewers = defReviewers.map((u) => ({\n user: { name: u.name },\n }));\n }\n\n const body: PartialDeep<BbsRestPr> = {\n title,\n description,\n fromRef: {\n id: `refs/heads/${sourceBranch}`,\n },\n toRef: {\n id: `refs/heads/${base}`,\n },\n reviewers,\n };\n let prInfoRes: HttpResponse<BbsRestPr>;\n try {\n prInfoRes = await bitbucketServerHttp.postJson<BbsRestPr>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests`,\n { body },\n );\n } catch (err) /* istanbul ignore next */ {\n if (\n err.body?.errors?.[0]?.exceptionName ===\n 'com.atlassian.bitbucket.pull.EmptyPullRequestException'\n ) {\n logger.debug(\n 'Empty pull request - deleting branch so it can be recreated next run',\n );\n await deleteBranch(sourceBranch);\n throw new Error(REPOSITORY_CHANGED);\n }\n throw err;\n }\n\n const pr: BbsPr = {\n ...utils.prInfo(prInfoRes.body),\n };\n\n // TODO #22198\n updatePrVersion(pr.number, pr.version!);\n\n // istanbul ignore if\n if (config.prList) {\n config.prList.push(pr);\n }\n\n return pr;\n}\n\nexport async function updatePr({\n number: prNo,\n prTitle: title,\n prBody: rawDescription,\n state,\n bitbucketInvalidReviewers,\n targetBranch,\n}: UpdatePrConfig & {\n bitbucketInvalidReviewers: string[] | undefined;\n}): Promise<void> {\n const description = sanitize(rawDescription);\n logger.debug(`updatePr(${prNo}, title=${title})`);\n\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw Object.assign(new Error(REPOSITORY_NOT_FOUND), { statusCode: 404 });\n }\n\n const body: any = {\n title,\n description,\n version: pr.version,\n reviewers: pr.reviewers\n ?.filter((name: string) => !bitbucketInvalidReviewers?.includes(name))\n .map((name: string) => ({ user: { name } })),\n };\n if (targetBranch) {\n body.toRef = {\n id: getNewBranchName(targetBranch),\n };\n }\n\n const { body: updatedPr } = await bitbucketServerHttp.putJson<{\n version: number;\n state: string;\n }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n { body },\n );\n\n updatePrVersion(prNo, updatedPr.version);\n\n const currentState = updatedPr.state;\n // TODO #22198\n const newState = {\n ['open']: 'OPEN',\n ['closed']: 'DECLINED',\n }[state!];\n\n if (\n newState &&\n ['OPEN', 'DECLINED'].includes(currentState) &&\n currentState !== newState\n ) {\n const command = state === 'open' ? 'reopen' : 'decline';\n const { body: updatedStatePr } = await bitbucketServerHttp.postJson<{\n version: number;\n }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${pr.number}/${command}?version=${updatedPr.version}`,\n );\n\n updatePrVersion(pr.number, updatedStatePr.version);\n }\n } catch (err) {\n logger.debug({ err, prNo }, `Failed to update PR`);\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (err.statusCode === 409) {\n if (utils.isInvalidReviewersResponse(err) && !bitbucketInvalidReviewers) {\n // Retry again with invalid reviewers being removed\n const invalidReviewers = utils.getInvalidReviewers(err);\n await updatePr({\n number: prNo,\n prTitle: title,\n prBody: rawDescription,\n state,\n bitbucketInvalidReviewers: invalidReviewers,\n });\n } else {\n throw new Error(REPOSITORY_CHANGED);\n }\n } else {\n throw err;\n }\n }\n}\n\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-rest.html#idp261\nexport async function mergePr({\n branchName,\n id: prNo,\n}: MergePRConfig): Promise<boolean> {\n logger.debug(`mergePr(${prNo}, ${branchName!})`);\n // Used for \"automerge\" feature\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw Object.assign(new Error(REPOSITORY_NOT_FOUND), { statusCode: 404 });\n }\n const { body } = await bitbucketServerHttp.postJson<{ version: number }>(\n // TODO: types (#22198)\n `./rest/api/1.0/projects/${config.projectKey}/repos/${\n config.repositorySlug\n }/pull-requests/${prNo}/merge?version=${pr.version!}`,\n );\n updatePrVersion(prNo, body.version);\n } catch (err) {\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (err.statusCode === 409) {\n logger.warn({ err }, `Failed to merge PR`);\n return false;\n } else {\n logger.warn({ err }, `Failed to merge PR`);\n return false;\n }\n }\n\n logger.debug(`PR merged, PrNo:${prNo}`);\n return true;\n}\n\nexport function massageMarkdown(input: string): string {\n logger.debug(`massageMarkdown(${input.split(newlineRegex)[0]})`);\n // Remove any HTML we use\n return smartTruncate(input, maxBodyLength())\n .replace(\n 'you tick the rebase/retry checkbox',\n 'PR is renamed to start with \"rebase!\"',\n )\n .replace(\n 'checking the rebase/retry box above',\n 'renaming the PR to start with \"rebase!\"',\n )\n .replace(regEx(/<\\/?summary>/g), '**')\n .replace(regEx(/<\\/?details>/g), '')\n .replace(regEx(`\\n---\\n\\n.*?<!-- rebase-check -->.*?(\\n|$)`), '')\n .replace(regEx(/<!--.*?-->/gs), '');\n}\n\nexport function maxBodyLength(): number {\n return 30000;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/modules/platform/bitbucket-server/index.ts"],"names":[],"mappings":";;;AAsFA,oCAoFC;AAGD,4BAgBC;AAED,gCAkBC;AAED,kCAQC;AAGD,4BA4EC;AAED,oDAiBC;AAED,sBAsBC;AAwBD,8BAsBC;AAID,wBAyCC;AAGD,kCAOC;AAGD,8BAKC;AAoBD,0CA0BC;AAiBD,oDA0BC;AAED,0CAiDC;AAKD,8BAQC;AAGD,kCAUC;AAGD,oCAQC;AAGD,gDAQC;AAED,oCAQC;AAED,oCASC;AA2ED,kCAMC;AAuED,sCAkDC;AAED,oDA6BC;AAOD,4BA+EC;AAED,4BA6GC;AAGD,0BAgCC;AAED,0CAgBC;AAED,sCAEC;;AA1nCD,8CAA6C;AAC7C,4DAA4B;AAE5B,sEAI2C;AAC3C,4CAAyC;AAGzC,iDAAiD;AACjD,+DAAyC;AACzC,2CAAiD;AACjD,4EAAsD;AACtD,0EAG6C;AAE7C,+CAA0D;AAC1D,qDAAkD;AAClD,2CAAwE;AAkBxE,kCAA4D;AAC5D,8CAAiD;AACjD,qCAAsC;AAStC,uDAAiC;AACjC,mCAA4C;AAE5C;;;;;;;;GAQG;AAEU,QAAA,EAAE,GAAG,kBAAkB,CAAC;AAErC,IAAI,MAAM,GAAc,EAAS,CAAC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cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { setTimeout } from 'timers/promises';\nimport semver from 'semver';\nimport type { PartialDeep } from 'type-fest';\nimport {\n REPOSITORY_CHANGED,\n REPOSITORY_EMPTY,\n REPOSITORY_NOT_FOUND,\n} from '../../../constants/error-messages';\nimport { logger } from '../../../logger';\nimport type { BranchStatus } from '../../../types';\nimport type { FileData } from '../../../types/platform/bitbucket-server';\nimport { parseJson } from '../../../util/common';\nimport * as git from '../../../util/git';\nimport { deleteBranch } from '../../../util/git';\nimport * as hostRules from '../../../util/host-rules';\nimport {\n BitbucketServerHttp,\n setBaseUrl,\n} from '../../../util/http/bitbucket-server';\nimport type { HttpOptions, HttpResponse } from '../../../util/http/types';\nimport { newlineRegex, regEx } from '../../../util/regex';\nimport { sanitize } from '../../../util/sanitize';\nimport { ensureTrailingSlash, getQueryString } from '../../../util/url';\nimport type {\n BranchStatusConfig,\n CreatePRConfig,\n EnsureCommentConfig,\n EnsureCommentRemovalConfig,\n EnsureIssueConfig,\n EnsureIssueResult,\n FindPRConfig,\n Issue,\n MergePRConfig,\n PlatformParams,\n PlatformResult,\n Pr,\n RepoParams,\n RepoResult,\n UpdatePrConfig,\n} from '../types';\nimport { getNewBranchName, repoFingerprint } from '../util';\nimport { smartTruncate } from '../utils/pr-body';\nimport { UserSchema } from './schema';\nimport type {\n BbsConfig,\n BbsPr,\n BbsRestBranch,\n BbsRestPr,\n BbsRestRepo,\n BbsRestUserRef,\n} from './types';\nimport * as utils from './utils';\nimport { getExtraCloneOpts } from './utils';\n\n/*\n * Version: 5.3 (EOL Date: 15 Aug 2019)\n * See following docs for api information:\n * https://docs.atlassian.com/bitbucket-server/rest/5.3.0/bitbucket-rest.html\n * https://docs.atlassian.com/bitbucket-server/rest/5.3.0/bitbucket-build-rest.html\n *\n * See following page for uptodate supported versions\n * https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html#AtlassianSupportEndofLifePolicy-BitbucketServer\n */\n\nexport const id = 'bitbucket-server';\n\nlet config: BbsConfig = {} as any;\n\nconst bitbucketServerHttp = new BitbucketServerHttp();\n\nconst defaults: {\n endpoint?: string;\n hostType: string;\n version: string;\n} = {\n hostType: 'bitbucket-server',\n version: '0.0.0',\n};\n\n/* istanbul ignore next */\nfunction updatePrVersion(pr: number, version: number): number {\n const res = Math.max(config.prVersions.get(pr) ?? 0, version);\n config.prVersions.set(pr, res);\n return res;\n}\n\nexport async function initPlatform({\n endpoint,\n token,\n username,\n password,\n gitAuthor,\n}: PlatformParams): Promise<PlatformResult> {\n if (!endpoint) {\n throw new Error('Init: You must configure a Bitbucket Server endpoint');\n }\n if (!(username && password) && !token) {\n throw new Error(\n 'Init: You must either configure a Bitbucket Server username/password or a HTTP access token',\n );\n } else if (password && token) {\n throw new Error(\n 'Init: You must configure either a Bitbucket Server password or a HTTP access token, not both',\n );\n }\n // TODO: Add a connection check that endpoint/username/password combination are valid (#9595)\n defaults.endpoint = ensureTrailingSlash(endpoint);\n setBaseUrl(defaults.endpoint);\n const platformConfig: PlatformResult = {\n endpoint: defaults.endpoint,\n };\n try {\n let bitbucketServerVersion: string;\n // istanbul ignore if: experimental feature\n if (process.env.RENOVATE_X_PLATFORM_VERSION) {\n bitbucketServerVersion = process.env.RENOVATE_X_PLATFORM_VERSION;\n } else {\n const { version } = (\n await bitbucketServerHttp.getJson<{ version: string }>(\n `./rest/api/1.0/application-properties`,\n )\n ).body;\n bitbucketServerVersion = version;\n logger.debug('Bitbucket Server version is: ' + bitbucketServerVersion);\n }\n\n if (semver.valid(bitbucketServerVersion)) {\n defaults.version = bitbucketServerVersion;\n }\n } catch (err) {\n logger.debug(\n { err },\n 'Error authenticating with Bitbucket. Check that your token includes \"api\" permissions',\n );\n }\n\n if (!gitAuthor && username) {\n logger.debug(`Attempting to confirm gitAuthor from username`);\n const options: HttpOptions = {\n memCache: false,\n };\n\n if (token) {\n options.token = token;\n } else {\n options.username = username;\n options.password = password;\n }\n\n try {\n const { displayName, emailAddress } = (\n await bitbucketServerHttp.getJson(\n `./rest/api/1.0/users/${username}`,\n options,\n UserSchema,\n )\n ).body;\n\n platformConfig.gitAuthor = `${displayName} <${emailAddress}>`;\n\n logger.debug(`Detected gitAuthor: ${platformConfig.gitAuthor}`);\n } catch (err) {\n logger.debug(\n { err },\n 'Failed to get user info, fallback gitAuthor will be used',\n );\n }\n }\n\n return platformConfig;\n}\n\n// Get all repositories that the user has access to\nexport async function getRepos(): Promise<string[]> {\n logger.debug('Autodiscovering Bitbucket Server repositories');\n try {\n const repos = await utils.accumulateValues(\n `./rest/api/1.0/repos?permission=REPO_WRITE&state=AVAILABLE`,\n );\n const result = repos.map(\n (r: { project: { key: string }; slug: string }) =>\n `${r.project.key}/${r.slug}`,\n );\n logger.debug({ result }, 'result of getRepos()');\n return result;\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, `bitbucket getRepos error`);\n throw err;\n }\n}\n\nexport async function getRawFile(\n fileName: string,\n repoName?: string,\n branchOrTag?: string,\n): Promise<string | null> {\n const repo = repoName ?? config.repository;\n const [project, slug] = repo.split('/');\n const fileUrl =\n `./rest/api/1.0/projects/${project}/repos/${slug}/browse/${fileName}?limit=20000` +\n (branchOrTag ? '&at=' + branchOrTag : '');\n const res = await bitbucketServerHttp.getJson<FileData>(fileUrl);\n const { isLastPage, lines, size } = res.body;\n if (isLastPage) {\n return lines.map(({ text }) => text).join('\\n');\n }\n const msg = `The file is too big (${size}B)`;\n logger.warn({ size }, msg);\n throw new Error(msg);\n}\n\nexport async function getJsonFile(\n fileName: string,\n repoName?: string,\n branchOrTag?: string,\n): Promise<any> {\n // TODO #22198\n const raw = await getRawFile(fileName, repoName, branchOrTag);\n return parseJson(raw, fileName);\n}\n\n// Initialize Bitbucket Server by getting base branch\nexport async function initRepo({\n repository,\n cloneSubmodules,\n ignorePrAuthor,\n gitUrl,\n}: RepoParams): Promise<RepoResult> {\n logger.debug(`initRepo(\"${JSON.stringify({ repository }, null, 2)}\")`);\n const opts = hostRules.find({\n hostType: defaults.hostType,\n url: defaults.endpoint,\n });\n\n const [projectKey, repositorySlug] = repository.split('/');\n\n config = {\n projectKey,\n repositorySlug,\n repository,\n prVersions: new Map<number, number>(),\n username: opts.username,\n ignorePrAuthor,\n } as any;\n\n try {\n const info = (\n await bitbucketServerHttp.getJson<BbsRestRepo>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}`,\n )\n ).body;\n config.owner = info.project.key;\n logger.debug(`${repository} owner = ${config.owner}`);\n const branchRes = await bitbucketServerHttp.getJson<BbsRestBranch>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/branches/default`,\n );\n\n // 204 means empty, 404 means repo not found or missing default branch. repo must exist here.\n if ([204, 404].includes(branchRes.statusCode)) {\n throw new Error(REPOSITORY_EMPTY);\n }\n\n const url = utils.getRepoGitUrl(\n config.repositorySlug,\n // TODO #22198\n defaults.endpoint!,\n gitUrl,\n info,\n opts,\n );\n\n await git.initRepo({\n ...config,\n url,\n extraCloneOpts: getExtraCloneOpts(opts),\n cloneSubmodules,\n fullClone: semver.lte(defaults.version, '8.0.0'),\n });\n\n config.mergeMethod = 'merge';\n const repoConfig: RepoResult = {\n defaultBranch: branchRes.body.displayId,\n isFork: !!info.origin,\n repoFingerprint: repoFingerprint(info.id, defaults.endpoint),\n };\n\n return repoConfig;\n } catch (err) /* istanbul ignore next */ {\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n }\n if (err.message === REPOSITORY_EMPTY) {\n throw err;\n }\n\n logger.debug({ err }, 'Unknown Bitbucket initRepo error');\n throw err;\n }\n}\n\nexport async function getBranchForceRebase(\n _branchName: string,\n): Promise<boolean> {\n // https://docs.atlassian.com/bitbucket-server/rest/7.0.1/bitbucket-rest.html#idp342\n const res = await bitbucketServerHttp.getJson<{\n mergeConfig: { defaultStrategy: { id: string } };\n }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/settings/pull-requests`,\n );\n\n // If the default merge strategy contains `ff-only` the PR can only be merged\n // if it is up to date with the base branch.\n // The current options for id are:\n // no-ff, ff, ff-only, rebase-no-ff, rebase-ff-only, squash, squash-ff-only\n return Boolean(\n res.body?.mergeConfig?.defaultStrategy?.id.includes('ff-only'),\n );\n}\n// Gets details for a PR\nexport async function getPr(\n prNo: number,\n refreshCache?: boolean,\n): Promise<BbsPr | null> {\n logger.debug(`getPr(${prNo})`);\n if (!prNo) {\n return null;\n }\n\n const res = await bitbucketServerHttp.getJson<BbsRestPr>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n { memCache: !refreshCache },\n );\n\n const pr: BbsPr = {\n ...utils.prInfo(res.body),\n reviewers: res.body.reviewers.map((r) => r.user.name),\n };\n // TODO #22198\n pr.version = updatePrVersion(pr.number, pr.version!);\n\n return pr;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nfunction matchesState(state: string, desiredState: string): boolean {\n if (desiredState === 'all') {\n return true;\n }\n if (desiredState.startsWith('!')) {\n return state !== desiredState.substring(1);\n }\n return state === desiredState;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nconst isRelevantPr =\n (branchName: string, prTitle: string | null | undefined, state: string) =>\n (p: Pr): boolean =>\n p.sourceBranch === branchName &&\n (!prTitle || p.title.toUpperCase() === prTitle.toUpperCase()) &&\n matchesState(p.state, state);\n\n// TODO: coverage (#9624)\nexport async function getPrList(refreshCache?: boolean): Promise<Pr[]> {\n logger.debug(`getPrList()`);\n // istanbul ignore next\n if (!config.prList || refreshCache) {\n const searchParams: Record<string, string> = {\n state: 'ALL',\n };\n if (!config.ignorePrAuthor && config.username !== undefined) {\n searchParams['role.1'] = 'AUTHOR';\n searchParams['username.1'] = config.username;\n }\n const query = getQueryString(searchParams);\n const values = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?${query}`,\n );\n\n config.prList = values.map(utils.prInfo);\n logger.debug(`Retrieved Pull Requests, count: ${config.prList.length}`);\n } else {\n logger.debug('returning cached PR list');\n }\n return config.prList;\n}\n\n// TODO: coverage (#9624)\n// istanbul ignore next\nexport async function findPr({\n branchName,\n prTitle,\n state = 'all',\n refreshCache,\n includeOtherAuthors,\n}: FindPRConfig): Promise<Pr | null> {\n logger.debug(`findPr(${branchName}, \"${prTitle!}\", \"${state}\")`);\n\n if (includeOtherAuthors) {\n // PR might have been created by anyone, so don't use the cached Renovate PR list\n const searchParams: Record<string, string> = {\n state: 'OPEN',\n };\n searchParams['direction'] = 'outgoing';\n searchParams['at'] = `refs/heads/${branchName}`;\n\n const query = getQueryString(searchParams);\n const prs = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?${query}`,\n 'get',\n {},\n 1, // only fetch the latest pr\n );\n\n if (!prs.length) {\n logger.debug(`No PR found for branch ${branchName}`);\n return null;\n }\n\n return utils.prInfo(prs[0]);\n }\n\n const prList = await getPrList(refreshCache);\n const pr = prList.find(isRelevantPr(branchName, prTitle, state));\n if (pr) {\n logger.debug(`Found PR #${pr.number}`);\n } else {\n logger.debug(`Renovate did not find a PR for branch #${branchName}`);\n }\n return pr ?? null;\n}\n\n// Returns the Pull Request for a branch. Null if not exists.\nexport async function getBranchPr(branchName: string): Promise<BbsPr | null> {\n logger.debug(`getBranchPr(${branchName})`);\n const existingPr = await findPr({\n branchName,\n state: 'open',\n });\n return existingPr ? getPr(existingPr.number) : null;\n}\n\n// istanbul ignore next\nexport async function refreshPr(number: number): Promise<void> {\n // wait for pr change propagation\n await setTimeout(1000);\n // refresh cache\n await getPr(number, true);\n}\n\nasync function getStatus(\n branchName: string,\n memCache = true,\n): Promise<utils.BitbucketCommitStatus> {\n const branchCommit = git.getBranchCommit(branchName);\n\n return (\n await bitbucketServerHttp.getJson<utils.BitbucketCommitStatus>(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/stats/${branchCommit!}`,\n { memCache },\n )\n ).body;\n}\n\n// Returns the combined status for a branch.\n// umbrella for status checks\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-build-rest.html#idp2\nexport async function getBranchStatus(\n branchName: string,\n): Promise<BranchStatus> {\n logger.debug(`getBranchStatus(${branchName})`);\n\n if (!git.branchExists(branchName)) {\n logger.debug('Branch does not exist - cannot fetch status');\n throw new Error(REPOSITORY_CHANGED);\n }\n\n try {\n const commitStatus = await getStatus(branchName);\n\n logger.debug({ commitStatus }, 'branch status check result');\n\n if (commitStatus.failed > 0) {\n return 'red';\n }\n if (commitStatus.inProgress > 0) {\n return 'yellow';\n }\n return commitStatus.successful > 0 ? 'green' : 'yellow';\n } catch (err) {\n logger.warn({ err }, `Failed to get branch status`);\n return 'red';\n }\n}\n\nfunction getStatusCheck(\n branchName: string,\n memCache = true,\n): Promise<utils.BitbucketStatus[]> {\n const branchCommit = git.getBranchCommit(branchName);\n\n return utils.accumulateValues(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/${branchCommit!}`,\n 'get',\n { memCache },\n );\n}\n\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-build-rest.html#idp2\nexport async function getBranchStatusCheck(\n branchName: string,\n context: string,\n): Promise<BranchStatus | null> {\n logger.debug(`getBranchStatusCheck(${branchName}, context=${context})`);\n\n try {\n const states = await getStatusCheck(branchName);\n\n for (const state of states) {\n if (state.key === context) {\n switch (state.state) {\n case 'SUCCESSFUL':\n return 'green';\n case 'INPROGRESS':\n return 'yellow';\n case 'FAILED':\n default:\n return 'red';\n }\n }\n }\n } catch (err) {\n logger.warn({ err }, `Failed to check branch status`);\n }\n return null;\n}\n\nexport async function setBranchStatus({\n branchName,\n context,\n description,\n state,\n url: targetUrl,\n}: BranchStatusConfig): Promise<void> {\n logger.debug(`setBranchStatus(${branchName})`);\n\n const existingStatus = await getBranchStatusCheck(branchName, context);\n if (existingStatus === state) {\n return;\n }\n logger.debug({ branch: branchName, context, state }, 'Setting branch status');\n\n const branchCommit = git.getBranchCommit(branchName);\n\n try {\n const body: any = {\n key: context,\n description,\n url: targetUrl ?? 'https://renovatebot.com',\n };\n\n switch (state) {\n case 'green':\n body.state = 'SUCCESSFUL';\n break;\n case 'yellow':\n body.state = 'INPROGRESS';\n break;\n case 'red':\n default:\n body.state = 'FAILED';\n break;\n }\n\n await bitbucketServerHttp.postJson(\n // TODO: types (#22198)\n `./rest/build-status/1.0/commits/${branchCommit!}`,\n { body },\n );\n\n // update status cache\n await getStatus(branchName, false);\n await getStatusCheck(branchName, false);\n } catch (err) {\n logger.warn({ err }, `Failed to set branch status`);\n }\n}\n\n// Issue\n\n/* istanbul ignore next */\nexport function findIssue(title: string): Promise<Issue | null> {\n logger.debug(`findIssue(${title})`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve(null);\n}\n\n/* istanbul ignore next */\nexport function ensureIssue({\n title,\n}: EnsureIssueConfig): Promise<EnsureIssueResult | null> {\n logger.warn({ title }, 'Cannot ensure issue');\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve(null);\n}\n\n/* istanbul ignore next */\nexport function getIssueList(): Promise<Issue[]> {\n logger.debug(`getIssueList()`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve([]);\n}\n\n/* istanbul ignore next */\nexport function ensureIssueClosing(title: string): Promise<void> {\n logger.debug(`ensureIssueClosing(${title})`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\nexport function addAssignees(iid: number, assignees: string[]): Promise<void> {\n logger.debug(`addAssignees(${iid}, [${assignees.join(', ')}])`);\n // This is used by Renovate when creating its own issues,\n // e.g. for deprecated package warnings,\n // config error notifications, or \"dependencyDashboard\"\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\nexport async function addReviewers(\n prNo: number,\n reviewers: string[],\n): Promise<void> {\n logger.debug(`Adding reviewers '${reviewers.join(', ')}' to #${prNo}`);\n\n await retry(updatePRAndAddReviewers, [prNo, reviewers], 3, [\n REPOSITORY_CHANGED,\n ]);\n}\n\nasync function updatePRAndAddReviewers(\n prNo: number,\n reviewers: string[],\n): Promise<void> {\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw new Error(REPOSITORY_NOT_FOUND);\n }\n\n // TODO: can `reviewers` be undefined? (#22198)\n const reviewersSet = new Set([...pr.reviewers!, ...reviewers]);\n\n await bitbucketServerHttp.putJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n {\n body: {\n title: pr.title,\n version: pr.version,\n reviewers: Array.from(reviewersSet).map((name) => ({\n user: { name },\n })),\n },\n },\n );\n await getPr(prNo, true);\n } catch (err) {\n logger.warn({ err, reviewers, prNo }, `Failed to add reviewers`);\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (\n err.statusCode === 409 &&\n !utils.isInvalidReviewersResponse(err)\n ) {\n logger.debug(\n '409 response to adding reviewers - has repository changed?',\n );\n throw new Error(REPOSITORY_CHANGED);\n } else {\n throw err;\n }\n }\n}\n\nasync function retry<T extends (...arg0: any[]) => Promise<any>>(\n fn: T,\n args: Parameters<T>,\n maxTries: number,\n retryErrorMessages: string[],\n): Promise<Awaited<ReturnType<T>>> {\n const maxAttempts = Math.max(maxTries, 1);\n let lastError: Error | undefined;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn(...args);\n } catch (e) {\n lastError = e;\n if (\n retryErrorMessages.length !== 0 &&\n !retryErrorMessages.includes(e.message)\n ) {\n logger.debug(`Error not marked for retry`);\n throw e;\n }\n }\n }\n\n logger.debug(`All ${maxAttempts} retry attempts exhausted`);\n // Can't be `undefined` here.\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw lastError;\n}\n\nexport function deleteLabel(issueNo: number, label: string): Promise<void> {\n logger.debug(`deleteLabel(${issueNo}, ${label})`);\n // Only used for the \"request Renovate to rebase a PR using a label\" feature\n //\n // Bitbucket Server does not have issues\n return Promise.resolve();\n}\n\ntype Comment = { text: string; id: number };\n\nasync function getComments(prNo: number): Promise<Comment[]> {\n // GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities\n let comments = await utils.accumulateValues(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/activities`,\n );\n\n comments = comments\n .filter(\n (a: { action: string; commentAction: string }) =>\n a.action === 'COMMENTED' && a.commentAction === 'ADDED',\n )\n .map((a: { comment: Comment }) => a.comment);\n\n logger.debug(`Found ${comments.length} comments`);\n\n return comments;\n}\n\nasync function addComment(prNo: number, text: string): Promise<void> {\n // POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments\n await bitbucketServerHttp.postJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments`,\n {\n body: { text },\n },\n );\n}\n\nasync function getCommentVersion(\n prNo: number,\n commentId: number,\n): Promise<number> {\n // GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n const { version } = (\n await bitbucketServerHttp.getJson<{ version: number }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}`,\n )\n ).body;\n\n return version;\n}\n\nasync function editComment(\n prNo: number,\n commentId: number,\n text: string,\n): Promise<void> {\n const version = await getCommentVersion(prNo, commentId);\n\n // PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n await bitbucketServerHttp.putJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}`,\n {\n body: { text, version },\n },\n );\n}\n\nasync function deleteComment(prNo: number, commentId: number): Promise<void> {\n const version = await getCommentVersion(prNo, commentId);\n\n // DELETE /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}\n await bitbucketServerHttp.deleteJson(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}?version=${version}`,\n );\n}\n\nexport async function ensureComment({\n number,\n topic,\n content,\n}: EnsureCommentConfig): Promise<boolean> {\n const sanitizedContent = sanitize(content);\n try {\n const comments = await getComments(number);\n let body: string;\n let commentId: number | undefined;\n let commentNeedsUpdating: boolean | undefined;\n if (topic) {\n logger.debug(`Ensuring comment \"${topic}\" in #${number}`);\n body = `### ${topic}\\n\\n${sanitizedContent}`;\n comments.forEach((comment) => {\n if (comment.text.startsWith(`### ${topic}\\n\\n`)) {\n commentId = comment.id;\n commentNeedsUpdating = comment.text !== body;\n }\n });\n } else {\n logger.debug(`Ensuring content-only comment in #${number}`);\n body = `${sanitizedContent}`;\n comments.forEach((comment) => {\n if (comment.text === body) {\n commentId = comment.id;\n commentNeedsUpdating = false;\n }\n });\n }\n if (!commentId) {\n await addComment(number, body);\n logger.info(\n { repository: config.repository, prNo: number, topic },\n 'Comment added',\n );\n } else if (commentNeedsUpdating) {\n await editComment(number, commentId, body);\n logger.debug(\n { repository: config.repository, prNo: number },\n 'Comment updated',\n );\n } else {\n logger.debug('Comment is already update-to-date');\n }\n return true;\n } catch (err) /* istanbul ignore next */ {\n logger.warn({ err }, 'Error ensuring comment');\n return false;\n }\n}\n\nexport async function ensureCommentRemoval(\n deleteConfig: EnsureCommentRemovalConfig,\n): Promise<void> {\n try {\n const { number: prNo } = deleteConfig;\n const key =\n deleteConfig.type === 'by-topic'\n ? deleteConfig.topic\n : deleteConfig.content;\n logger.debug(`Ensuring comment \"${key}\" in #${prNo} is removed`);\n const comments = await getComments(prNo);\n\n let commentId: number | null | undefined = null;\n if (deleteConfig.type === 'by-topic') {\n const byTopic = (comment: Comment): boolean =>\n comment.text.startsWith(`### ${deleteConfig.topic}\\n\\n`);\n commentId = comments.find(byTopic)?.id;\n } else if (deleteConfig.type === 'by-content') {\n const byContent = (comment: Comment): boolean =>\n comment.text.trim() === deleteConfig.content;\n commentId = comments.find(byContent)?.id;\n }\n\n if (commentId) {\n await deleteComment(prNo, commentId);\n }\n } catch (err) /* istanbul ignore next */ {\n logger.warn({ err }, 'Error ensuring comment removal');\n }\n}\n\n// Pull Request\n\nconst escapeHash = (input: string): string =>\n input?.replace(regEx(/#/g), '%23');\n\nexport async function createPr({\n sourceBranch,\n targetBranch,\n prTitle: title,\n prBody: rawDescription,\n platformPrOptions,\n}: CreatePRConfig): Promise<Pr> {\n const description = sanitize(rawDescription);\n logger.debug(`createPr(${sourceBranch}, title=${title})`);\n const base = targetBranch;\n let reviewers: BbsRestUserRef[] = [];\n\n if (platformPrOptions?.bbUseDefaultReviewers) {\n logger.debug(`fetching default reviewers`);\n const { id } = (\n await bitbucketServerHttp.getJson<{ id: number }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}`,\n )\n ).body;\n\n const defReviewers = (\n await bitbucketServerHttp.getJson<{ name: string }[]>(\n `./rest/default-reviewers/1.0/projects/${config.projectKey}/repos/${\n config.repositorySlug\n }/reviewers?sourceRefId=refs/heads/${escapeHash(\n sourceBranch,\n )}&targetRefId=refs/heads/${base}&sourceRepoId=${id}&targetRepoId=${id}`,\n )\n ).body;\n\n reviewers = defReviewers.map((u) => ({\n user: { name: u.name },\n }));\n }\n\n const body: PartialDeep<BbsRestPr> = {\n title,\n description,\n fromRef: {\n id: `refs/heads/${sourceBranch}`,\n },\n toRef: {\n id: `refs/heads/${base}`,\n },\n reviewers,\n };\n let prInfoRes: HttpResponse<BbsRestPr>;\n try {\n prInfoRes = await bitbucketServerHttp.postJson<BbsRestPr>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests`,\n { body },\n );\n } catch (err) /* istanbul ignore next */ {\n if (\n err.body?.errors?.[0]?.exceptionName ===\n 'com.atlassian.bitbucket.pull.EmptyPullRequestException'\n ) {\n logger.debug(\n 'Empty pull request - deleting branch so it can be recreated next run',\n );\n await deleteBranch(sourceBranch);\n throw new Error(REPOSITORY_CHANGED);\n }\n throw err;\n }\n\n const pr: BbsPr = {\n ...utils.prInfo(prInfoRes.body),\n };\n\n // TODO #22198\n updatePrVersion(pr.number, pr.version!);\n\n // istanbul ignore if\n if (config.prList) {\n config.prList.push(pr);\n }\n\n return pr;\n}\n\nexport async function updatePr({\n number: prNo,\n prTitle: title,\n prBody: rawDescription,\n state,\n bitbucketInvalidReviewers,\n targetBranch,\n}: UpdatePrConfig & {\n bitbucketInvalidReviewers: string[] | undefined;\n}): Promise<void> {\n const description = sanitize(rawDescription);\n logger.debug(`updatePr(${prNo}, title=${title})`);\n\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw Object.assign(new Error(REPOSITORY_NOT_FOUND), { statusCode: 404 });\n }\n\n const body: any = {\n title,\n description,\n version: pr.version,\n reviewers: pr.reviewers\n ?.filter((name: string) => !bitbucketInvalidReviewers?.includes(name))\n .map((name: string) => ({ user: { name } })),\n };\n if (targetBranch) {\n body.toRef = {\n id: getNewBranchName(targetBranch),\n };\n }\n\n const { body: updatedPr } = await bitbucketServerHttp.putJson<\n BbsRestPr & {\n version: number;\n }\n >(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}`,\n { body },\n );\n\n updatePrVersion(prNo, updatedPr.version);\n\n const currentState = updatedPr.state;\n // TODO #22198\n const newState = {\n ['open']: 'OPEN',\n ['closed']: 'DECLINED',\n }[state!];\n\n let finalState: 'open' | 'closed' =\n currentState === 'OPEN' ? 'open' : 'closed';\n\n if (\n newState &&\n ['OPEN', 'DECLINED'].includes(currentState) &&\n currentState !== newState\n ) {\n const command = state === 'open' ? 'reopen' : 'decline';\n const { body: updatedStatePr } = await bitbucketServerHttp.postJson<{\n version: number;\n }>(\n `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${pr.number}/${command}?version=${updatedPr.version}`,\n );\n\n finalState = state!;\n\n updatePrVersion(pr.number, updatedStatePr.version);\n }\n\n if (config.prList) {\n const bbsPr = utils.prInfo(updatedPr);\n const existingIndex = config.prList.findIndex(\n (item) => item.number === prNo,\n );\n // istanbul ignore if: should never happen\n if (existingIndex === -1) {\n logger.warn(\n { pr: bbsPr },\n 'Possible error: Updated PR was not found in the PRs that were returned from getPrList().',\n );\n config.prList.push({ ...bbsPr, state: finalState });\n } else {\n config.prList[existingIndex] = { ...bbsPr, state: finalState };\n }\n }\n } catch (err) {\n logger.debug({ err, prNo }, `Failed to update PR`);\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (err.statusCode === 409) {\n if (utils.isInvalidReviewersResponse(err) && !bitbucketInvalidReviewers) {\n // Retry again with invalid reviewers being removed\n const invalidReviewers = utils.getInvalidReviewers(err);\n await updatePr({\n number: prNo,\n prTitle: title,\n prBody: rawDescription,\n state,\n bitbucketInvalidReviewers: invalidReviewers,\n });\n } else {\n throw new Error(REPOSITORY_CHANGED);\n }\n } else {\n throw err;\n }\n }\n}\n\n// https://docs.atlassian.com/bitbucket-server/rest/6.0.0/bitbucket-rest.html#idp261\nexport async function mergePr({\n branchName,\n id: prNo,\n}: MergePRConfig): Promise<boolean> {\n logger.debug(`mergePr(${prNo}, ${branchName!})`);\n // Used for \"automerge\" feature\n try {\n const pr = await getPr(prNo);\n if (!pr) {\n throw Object.assign(new Error(REPOSITORY_NOT_FOUND), { statusCode: 404 });\n }\n const { body } = await bitbucketServerHttp.postJson<{ version: number }>(\n // TODO: types (#22198)\n `./rest/api/1.0/projects/${config.projectKey}/repos/${\n config.repositorySlug\n }/pull-requests/${prNo}/merge?version=${pr.version!}`,\n );\n updatePrVersion(prNo, body.version);\n } catch (err) {\n if (err.statusCode === 404) {\n throw new Error(REPOSITORY_NOT_FOUND);\n } else if (err.statusCode === 409) {\n logger.warn({ err }, `Failed to merge PR`);\n return false;\n } else {\n logger.warn({ err }, `Failed to merge PR`);\n return false;\n }\n }\n\n logger.debug(`PR merged, PrNo:${prNo}`);\n return true;\n}\n\nexport function massageMarkdown(input: string): string {\n logger.debug(`massageMarkdown(${input.split(newlineRegex)[0]})`);\n // Remove any HTML we use\n return smartTruncate(input, maxBodyLength())\n .replace(\n 'you tick the rebase/retry checkbox',\n 'PR is renamed to start with \"rebase!\"',\n )\n .replace(\n 'checking the rebase/retry box above',\n 'renaming the PR to start with \"rebase!\"',\n )\n .replace(regEx(/<\\/?summary>/g), '**')\n .replace(regEx(/<\\/?details>/g), '')\n .replace(regEx(`\\n---\\n\\n.*?<!-- rebase-check -->.*?(\\n|$)`), '')\n .replace(regEx(/<!--.*?-->/gs), '');\n}\n\nexport function maxBodyLength(): number {\n return 30000;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "renovate",
3
3
  "description": "Automated dependency updates. Flexible so you don't need to be.",
4
- "version": "39.7.6",
4
+ "version": "39.8.0",
5
5
  "type": "commonjs",
6
6
  "bin": {
7
7
  "renovate": "dist/renovate.js",