Skip to content

Commit

Permalink
fix: name of PullRequestState and IssueState, which is used just by G…
Browse files Browse the repository at this point in the history
…itHub for now
  • Loading branch information
adelkahomolova committed Oct 21, 2019
1 parent 188eef6 commit 468c037
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 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,13 +2,13 @@ import { Repository } from '../../model';
import { isArray } from 'util';
import { inject, injectable } from 'inversify';
import { ErrorFactory } from '../../lib/errors/ErrorFactory';
import { CVSPullRequestState } from './ICVSService';
import * as nodePath from 'path';
import { Metadata, MetadataType, IProjectFilesBrowserService } from '../model';
import { Types } from '../../types';
import { ProjectIssueBrowserService as ContentRepositoryBrowserService } from '../../model';
import { Directory, File, Symlink } from './model';
import { GitServiceUtils } from './GitServiceUtils';
import { GitHubPullRequestState } from './IGitHubService';

@injectable()
export class Git implements IProjectFilesBrowserService {
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: CVSPullRequestState.all } }).then((r) => {
return this.service.getPullRequests(params.owner, params.repoName, { filter: { state: GitHubPullRequestState.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,9 +22,9 @@ 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 { CVSPullRequestState } from './ICVSService';
import { getRepoCommitsResponse } from './__MOCKS__/gitHubServiceMockFolder/getRepoCommitsResponse.mock';
import { File } from './model';
import { GitHubPullRequestState } from './IGitHubService';

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

const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: CVSPullRequestState.open } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.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: CVSPullRequestState.closed } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.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: CVSPullRequestState.all } });
const response = await service.getPullRequests('octocat', 'Hello-World', { filter: { state: GitHubPullRequestState.all } });
expect(response.items.map((item) => item.state)).toMatchObject(['open', 'closed']);
});
});
Expand Down
5 changes: 3 additions & 2 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, CVSPullRequestState } from './ICVSService';
import { ICVSService } from './ICVSService';
import { Paginated } from '../../inspectors/common/Paginated';
import {
IssuesListForRepoResponseItem,
Expand All @@ -32,6 +32,7 @@ import { Types } from '../../types';
import { ArgumentsProvider } from '../../inversify.config';
import { ICache } from '../../scanner/cache/ICache';
import { InMemoryCache } from '../../scanner/cache/InMemoryCahce';
import { GitHubPullRequestState } from './IGitHubService';
const debug = Debug('cli:services:git:github-service');

@injectable()
Expand Down Expand Up @@ -68,7 +69,7 @@ export class GitHubService implements ICVSService {
async getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: CVSPullRequestState }>,
options?: ListGetterOptions<{ state?: GitHubPullRequestState }>,
): Promise<Paginated<PullRequest>> {
let url = 'GET /repos/:owner/:repo/pulls';
if (options !== undefined && options.filter !== undefined && options.filter.state !== undefined) {
Expand Down
15 changes: 2 additions & 13 deletions src/services/git/ICVSService.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ListGetterOptions } from '../../inspectors/common/ListGetterOptions';
import { PullRequest, PullRequestReview, Commit, Contributor, ContributorStats, Issue, Directory, File, Symlink, PullFiles } from './model';
import { Paginated } from '../../inspectors/common/Paginated';
import { GitHubPullRequestState } from './IGitHubService';

export interface ICVSService {
getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: CVSPullRequestState }>,
options?: ListGetterOptions<{ state?: GitHubPullRequestState }>,
): 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 @@ -18,15 +19,3 @@ export interface ICVSService {
getIssue(owner: string, repo: string, issueNumber: number): Promise<Issue>;
getRepoContent(owner: string, repo: string, path: string): Promise<File | Symlink | Directory | null>;
}

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

export enum CVSIssueState {
open = 'open',
closed = 'closed',
all = 'all',
}

0 comments on commit 468c037

Please sign in to comment.