Skip to content

Commit

Permalink
fix: return issue is as a string,
Browse files Browse the repository at this point in the history
fix: name of pullRequestState and issueState
  • Loading branch information
adelkahomolova committed Oct 21, 2019
1 parent 13d79f0 commit 3b84e02
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/services/git/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Repository } from '../../model';
import { isArray } from 'util';
import { inject, injectable } from 'inversify';
import { ErrorFactory } from '../../lib/errors/ErrorFactory';
import { GitHubPullRequestState } from './ICVSService';
import { CVSPullRequestState } from './ICVSService';
import * as nodePath from 'path';
import { Metadata, MetadataType, IProjectFilesBrowserService } from '../model';
import { Types } from '../../types';
Expand Down Expand Up @@ -115,7 +115,7 @@ export class Git implements IProjectFilesBrowserService {

async getPullRequestCount(): Promise<number> {
const params = GitServiceUtils.getOwnerAndRepoName(this.repository.url);
return this.service.getPullRequests(params.owner, params.repoName, { filter: { state: GitHubPullRequestState.all } }).then((r) => {
return this.service.getPullRequests(params.owner, params.repoName, { filter: { state: CVSPullRequestState.all } }).then((r) => {
if (!r) {
throw ErrorFactory.newInternalError('Could not get pull requests');
}
Expand Down
8 changes: 4 additions & 4 deletions src/services/git/GitHubService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getPullsFilesServiceResponse } from './__MOCKS__/gitHubServiceMockFolde
import { getPullCommitsResponse } from './__MOCKS__/gitHubServiceMockFolder/getPullsCommitsResponse.mock';
import { getPullCommitsServiceResponse } from './__MOCKS__/gitHubServiceMockFolder/getPullCommitsServiceResponse.mock';
import { GitHubNock } from '../../../test/helpers/gitHubNock';
import { GitHubPullRequestState } from './ICVSService';
import { CVSPullRequestState } from './ICVSService';
import { getRepoCommitsResponse } from './__MOCKS__/gitHubServiceMockFolder/getRepoCommitsResponse.mock';
import { File } from './model';

Expand Down Expand Up @@ -70,7 +70,7 @@ describe('GitHub Service', () => {
'open',
);

const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.open } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: CVSPullRequestState.open } });
expect(response.items.map((item) => item.state)).toMatchObject(['open']);
});

Expand All @@ -80,7 +80,7 @@ describe('GitHub Service', () => {
'closed',
);

const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.closed } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: CVSPullRequestState.closed } });
expect(response.items.map((item) => item.state)).toMatchObject(['closed']);
});

Expand All @@ -93,7 +93,7 @@ describe('GitHub Service', () => {
'all',
);

const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.all } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: CVSPullRequestState.all } });
expect(response.items.map((item) => item.state)).toMatchObject(['open', 'closed']);
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/services/git/GitHubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
IssueComment,
Symlink,
} from './model';
import { ICVSService, GitHubPullRequestState } from './ICVSService';
import { ICVSService, CVSPullRequestState } from './ICVSService';
import { Paginated } from '../../inspectors/common/Paginated';
import {
IssuesListForRepoResponseItem,
Expand Down Expand Up @@ -68,7 +68,7 @@ export class GitHubService implements ICVSService {
async getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: GitHubPullRequestState }>,
options?: ListGetterOptions<{ state?: CVSPullRequestState }>,
): Promise<Paginated<PullRequest>> {
let url = 'GET /repos/:owner/:repo/pulls';
if (options !== undefined && options.filter !== undefined && options.filter.state !== undefined) {
Expand Down Expand Up @@ -326,7 +326,7 @@ export class GitHubService implements ICVSService {
updatedAt: val.updated_at,
closedAt: val.closed_at,
state: val.state,
id: val.id,
id: val.id.toString(),
pullRequestUrl: val.pull_request && val.pull_request.url,
}));
const pagination = this.getPagination(response.length);
Expand All @@ -342,7 +342,7 @@ export class GitHubService implements ICVSService {
const response = await this.unwrap(this.client.issues.get({ owner, repo, issue_number: issueNumber }));

return {
id: response.data.id,
id: response.data.id.toString(),
user: {
login: response.data.user.login,
id: response.data.user.id.toString(),
Expand Down
6 changes: 3 additions & 3 deletions src/services/git/ICVSService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ICVSService {
getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: GitHubPullRequestState }>,
options?: ListGetterOptions<{ state?: CVSPullRequestState }>,
): Promise<Paginated<PullRequest>>;
getPullRequestReviews(owner: string, repo: string, prNumber: number): Promise<Paginated<PullRequestReview>>;
getPullRequestFiles(owner: string, repo: string, prNumber: number): Promise<Paginated<PullFiles>>;
Expand All @@ -19,13 +19,13 @@ export interface ICVSService {
getRepoContent(owner: string, repo: string, path: string): Promise<File | Symlink | Directory | null>;
}

export enum GitHubPullRequestState {
export enum CVSPullRequestState {
open = 'open',
closed = 'closed',
all = 'all',
}

export enum GitHubIssueState {
export enum CVSIssueState {
open = 'open',
closed = 'closed',
all = 'all',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getIssuesServiceResponse: Paginated<Issue> = {
body: 'a',
closedAt: null,
createdAt: '2019-06-26T15:11:43Z',
id: 461030590,
id: "461030590",
pullRequestUrl: 'https://api.github.com/repos/octocat/Hello-World/pulls/513',
state: 'open',
updatedAt: '2019-06-26T15:11:43Z',
Expand All @@ -20,7 +20,7 @@ export const getIssuesServiceResponse: Paginated<Issue> = {
body: '',
closedAt: null,
createdAt: '2019-06-24T19:43:52Z',
id: 460062740,
id: "460062740",
pullRequestUrl: 'https://api.github.com/repos/octocat/Hello-World/pulls/512',
state: 'open',
updatedAt: '2019-06-24T19:43:52Z',
Expand Down
2 changes: 1 addition & 1 deletion src/services/git/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export type Directory = Array<RepoContent>;

export interface Issue {
user: UserInfo;
id: number | string;
id: string;
url: string;
body: string;
createdAt: string;
Expand Down

0 comments on commit 3b84e02

Please sign in to comment.