Skip to content
Snippets Groups Projects
Unverified Commit 4b7295ee authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

fix(bitbucket): Return proper type for "createPr()" (#9623)

parent d51b3aa4
No related branches found
No related tags found
No related merge requests found
......@@ -382,6 +382,7 @@ exports[`platform/bitbucket/index findPr() finds pr 1`] = `
Object {
"body": "summary",
"createdAt": "2018-07-02T07:02:25.275030+00:00",
"displayNumber": "Pull Request #5",
"number": 5,
"sourceBranch": "branch",
"state": "open",
......@@ -1158,6 +1159,7 @@ Array [
Object {
"body": undefined,
"createdAt": undefined,
"displayNumber": "Pull Request #1",
"number": 1,
"sourceBranch": "branch-a",
"state": "open",
......
......@@ -696,7 +696,7 @@ export async function createPr({
};
try {
const prInfo = (
const prRes = (
await bitbucketHttp.postJson<PrResponse>(
`/2.0/repositories/${config.repository}/pullrequests`,
{
......@@ -704,11 +704,7 @@ export async function createPr({
}
)
).body;
// TODO: fix types
const pr: Pr = {
number: prInfo.id,
displayNumber: `Pull Request #${prInfo.id}`,
} as any;
const pr = utils.prInfo(prRes);
// istanbul ignore if
if (config.prList) {
config.prList.push(pr);
......
......@@ -172,13 +172,14 @@ export interface PrResponse {
export function prInfo(pr: PrResponse): Pr {
return {
number: pr.id,
body: pr.summary ? pr.summary.raw : /* istanbul ignore next */ undefined,
sourceBranch: pr.source.branch.name,
targetBranch: pr.destination.branch.name,
displayNumber: `Pull Request #${pr.id}`,
body: pr.summary?.raw,
sourceBranch: pr.source?.branch?.name,
targetBranch: pr.destination?.branch?.name,
title: pr.title,
state: prStates.closed.includes(pr.state)
state: prStates.closed?.includes(pr.state)
? /* istanbul ignore next */ PrState.Closed
: pr.state.toLowerCase(),
: pr.state?.toLowerCase(),
createdAt: pr.created_on,
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment