Skip to content

Commit

Permalink
fix: add interface and fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Oct 17, 2019
1 parent 78c0dc5 commit 19d29d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,8 @@ export class BitbucketService implements ICVSService {
repo_slug: repo,
username: owner,
};
const response = <DeepRequired<Bitbucket.Response<{
next: string;
page: number;
pagelen: number;
previous: string;
size: number;
values: Bitbucket.Schema.Commit[];
}>>>await this.client.pullrequests.listCommits(params);

const response = <DeepRequired<Bitbucket.Response<BitbucketCommit>>>await this.client.pullrequests.listCommits(params);

const items = response.data.values.map((val) => ({
sha: val.sha,
Expand All @@ -174,14 +168,14 @@ export class BitbucketService implements ICVSService {
message: val.message,
author: {
name: val.author.raw,
email: undefined,
email: 'undefined',
date: val.date,
},
tree: {
sha: val.hash,
url: val.links.html.href,
},
verified: undefined,
verified: false,
},
}));
const pagination = this.getPagination(response.data);
Expand Down Expand Up @@ -314,7 +308,7 @@ export class BitbucketService implements ICVSService {
);
};

getPagination<T>(data: { next: string, previous: string, page: number, values: T[]}) {
getPagination<T>(data: { next: string; previous: string; page: number; values: T[] }) {
const hasNextPage = !!data.next;
const hasPreviousPage = !!data.previous;
const page = data.page;
Expand All @@ -324,3 +318,12 @@ export class BitbucketService implements ICVSService {
return { totalCount, hasNextPage, hasPreviousPage, page, perPage };
}
}

interface BitbucketCommit {
next: string;
page: number;
pagelen: number;
previous: string;
size: number;
values: Bitbucket.Schema.Commit[];
}
8 changes: 4 additions & 4 deletions test/helpers/bibucketNock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,25 +642,25 @@ export const getPullCommits = {
commit: {
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/f799951483319e5397d41019de50f8e07b01b04f',
message: 'Remove the duplicated (unnecessary items)',
author: { name: 'ashwinahuja', email: undefined, date: '2018-09-13T16:19:32+00:00' },
author: { name: 'ashwinahuja', email: 'undefined', date: '2018-09-13T16:19:32+00:00' },
tree: {
sha: 'f799951483319e5397d41019de50f8e07b01b04f',
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/f799951483319e5397d41019de50f8e07b01b04f',
},
verified: undefined,
verified: false,
},
},
{
sha: undefined,
commit: {
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/0e3d572c47c60df4760e541da6a05e5e305d6175',
message: 'Making datetime objects more compatible with old C extensions written for CPython',
author: { name: 'ashwinahuja', email: undefined, date: '2018-09-13T16:14:59+00:00' },
author: { name: 'ashwinahuja', email: 'undefined', date: '2018-09-13T16:14:59+00:00' },
tree: {
sha: '0e3d572c47c60df4760e541da6a05e5e305d6175',
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/0e3d572c47c60df4760e541da6a05e5e305d6175',
},
verified: undefined,
verified: false,
},
},
],
Expand Down

0 comments on commit 19d29d6

Please sign in to comment.