Skip to content

Commit

Permalink
fix: use different interfaces for GitHub PR and Bitbucket PR
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Nov 19, 2019
1 parent 572371b commit 7d2ecb5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/inspectors/CollaborationInspector.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { inject, injectable } from 'inversify';
import { ProjectIssueBrowserService as ContentRepositoryBrowserService } from '../model';
import { GitHubPullRequestState } from '../services/git/IGitHubService';
import { Types } from '../types';
import { ListGetterOptions } from './common/ListGetterOptions';
import { ICollaborationInspector, PullRequestState } from './ICollaborationInspector';
import { ICollaborationInspector } from './ICollaborationInspector';
import { BitbucketPullRequestState } from '../services/git/ICVSService';

@injectable()
export class CollaborationInspector implements ICollaborationInspector {
Expand All @@ -12,7 +14,11 @@ export class CollaborationInspector implements ICollaborationInspector {
this.service = service;
}

async getPullRequests(owner: string, repo: string, options?: ListGetterOptions<{ state?: PullRequestState }>) {
async getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: GitHubPullRequestState | BitbucketPullRequestState }>,
) {
return this.service.getPullRequests(owner, repo, options);
}

Expand Down
8 changes: 7 additions & 1 deletion src/inspectors/ICollaborationInspector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { PullCommits, PullFiles, PullRequest } from '../services/git/model';
import { ListGetterOptions } from './common/ListGetterOptions';
import { Paginated } from './common/Paginated';
import { GitHubPullRequestState } from '../services/git/IGitHubService';
import { BitbucketPullRequestState } from '../services/git/ICVSService';

export interface ICollaborationInspector {
getPullRequests(owner: string, repo: string, options?: ListGetterOptions<{ state?: PullRequestState }>): Promise<Paginated<PullRequest>>;
getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: GitHubPullRequestState | BitbucketPullRequestState }>,
): Promise<Paginated<PullRequest>>;
getPullRequest(owner: string, repo: string, prNumber: number): Promise<PullRequest>;
getPullCommits(owner: string, repo: string, prNumber: number): Promise<Paginated<PullCommits>>;
getPullRequestFiles(owner: string, repo: string, prNumber: number): Promise<Paginated<PullFiles>>;
Expand Down
11 changes: 9 additions & 2 deletions src/services/git/ICVSService.ts
Original file line number Diff line number Diff line change
@@ -1,13 +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';
import { Commit, Contributor, ContributorStats, Directory, File, Issue, PullFiles, PullRequest, PullRequestReview, Symlink } from './model';

export interface ICVSService {
getPullRequests(
owner: string,
repo: string,
options?: ListGetterOptions<{ state?: GitHubPullRequestState }>,
options?: ListGetterOptions<{ state?: GitHubPullRequestState | BitbucketPullRequestState }>,
): 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,3 +19,10 @@ 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 BitbucketPullRequestState {
open = 'OPEN',
closed = 'MERGED',
declined = 'DECLINED',
superseded = 'SUPERSEDED',
}

0 comments on commit 7d2ecb5

Please sign in to comment.