Skip to content

Commit 36cc563

Browse files
committed
Removes SearchedIssue and SearchedPullRequest wrappers,
because reasons are not used anymore (#4098, #4102)
1 parent b889ffb commit 36cc563

File tree

14 files changed

+189
-302
lines changed

14 files changed

+189
-302
lines changed

src/git/models/issue.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ export interface IssueRepository {
7676
id?: string;
7777
}
7878

79-
export interface SearchedIssue {
80-
issue: IssueShape;
81-
reasons: string[];
82-
}
83-
8479
export type IssueRepositoryIdentityDescriptor = RequireSomeWithProps<
8580
RequireSome<RepositoryIdentityDescriptor<string>, 'provider'>,
8681
'provider',

src/git/models/pullRequest.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,3 @@ export type PullRequestRepositoryIdentityDescriptor = RequireSomeWithProps<
185185
'id' | 'domain' | 'repoDomain' | 'repoName'
186186
> &
187187
RequireSomeWithProps<RequireSome<RepositoryIdentityDescriptor<string>, 'remote'>, 'remote', 'domain'>;
188-
189-
export interface SearchedPullRequest {
190-
pullRequest: PullRequest;
191-
reasons: string[];
192-
}

src/plus/integrations/integration.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ import { AuthenticationError, CancellationError, RequestClientError } from '../.
1414
import type { PagedResult } from '../../git/gitProvider';
1515
import type { Account, UnidentifiedAuthor } from '../../git/models/author';
1616
import type { DefaultBranch } from '../../git/models/defaultBranch';
17-
import type { Issue, SearchedIssue } from '../../git/models/issue';
17+
import type { Issue, IssueShape } from '../../git/models/issue';
1818
import type { IssueOrPullRequest } from '../../git/models/issueOrPullRequest';
19-
import type {
20-
PullRequest,
21-
PullRequestMergeMethod,
22-
PullRequestState,
23-
SearchedPullRequest,
24-
} from '../../git/models/pullRequest';
19+
import type { PullRequest, PullRequestMergeMethod, PullRequestState } from '../../git/models/pullRequest';
2520
import type { RepositoryMetadata } from '../../git/models/repositoryMetadata';
2621
import type { PullRequestUrlIdentity } from '../../git/utils/pullRequest.utils';
2722
import { showIntegrationDisconnectedTooManyFailedRequestsWarningMessage } from '../../messages';
@@ -418,16 +413,16 @@ export abstract class IntegrationBase<
418413
async searchMyIssues(
419414
resource?: ResourceDescriptor,
420415
cancellation?: CancellationToken,
421-
): Promise<SearchedIssue[] | undefined>;
416+
): Promise<IssueShape[] | undefined>;
422417
async searchMyIssues(
423418
resources?: ResourceDescriptor[],
424419
cancellation?: CancellationToken,
425-
): Promise<SearchedIssue[] | undefined>;
420+
): Promise<IssueShape[] | undefined>;
426421
@debug()
427422
async searchMyIssues(
428423
resources?: ResourceDescriptor | ResourceDescriptor[],
429424
cancellation?: CancellationToken,
430-
): Promise<SearchedIssue[] | undefined> {
425+
): Promise<IssueShape[] | undefined> {
431426
const scope = getLogScope();
432427
const connected = this.maybeConnected ?? (await this.isConnected());
433428
if (!connected) return undefined;
@@ -441,15 +436,15 @@ export abstract class IntegrationBase<
441436
this.resetRequestExceptionCount();
442437
return issues;
443438
} catch (ex) {
444-
return this.handleProviderException<SearchedIssue[] | undefined>(ex, scope, undefined);
439+
return this.handleProviderException<IssueShape[] | undefined>(ex, scope, undefined);
445440
}
446441
}
447442

448443
protected abstract searchProviderMyIssues(
449444
session: ProviderAuthenticationSession,
450445
resources?: ResourceDescriptor[],
451446
cancellation?: CancellationToken,
452-
): Promise<SearchedIssue[] | undefined>;
447+
): Promise<IssueShape[] | undefined>;
453448

454449
@debug()
455450
async getIssueOrPullRequest(
@@ -660,7 +655,7 @@ export abstract class IssueIntegration<
660655
async getIssuesForProject(
661656
project: T,
662657
options?: { user?: string; filters?: IssueFilter[] },
663-
): Promise<SearchedIssue[] | undefined> {
658+
): Promise<IssueShape[] | undefined> {
664659
const connected = this.maybeConnected ?? (await this.isConnected());
665660
if (!connected) return undefined;
666661

@@ -669,15 +664,15 @@ export abstract class IssueIntegration<
669664
this.resetRequestExceptionCount();
670665
return issues;
671666
} catch (ex) {
672-
return this.handleProviderException<SearchedIssue[] | undefined>(ex, undefined, undefined);
667+
return this.handleProviderException<IssueShape[] | undefined>(ex, undefined, undefined);
673668
}
674669
}
675670

676671
protected abstract getProviderIssuesForProject(
677672
session: ProviderAuthenticationSession,
678673
project: T,
679674
options?: { user?: string; filters?: IssueFilter[] },
680-
): Promise<SearchedIssue[] | undefined>;
675+
): Promise<IssueShape[] | undefined>;
681676
}
682677

683678
export abstract class HostingIntegration<
@@ -1293,18 +1288,18 @@ export abstract class HostingIntegration<
12931288
repo?: T,
12941289
cancellation?: CancellationToken,
12951290
silent?: boolean,
1296-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>>;
1291+
): Promise<IntegrationResult<PullRequest[] | undefined>>;
12971292
async searchMyPullRequests(
12981293
repos?: T[],
12991294
cancellation?: CancellationToken,
13001295
silent?: boolean,
1301-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>>;
1296+
): Promise<IntegrationResult<PullRequest[] | undefined>>;
13021297
@debug()
13031298
async searchMyPullRequests(
13041299
repos?: T | T[],
13051300
cancellation?: CancellationToken,
13061301
silent?: boolean,
1307-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>> {
1302+
): Promise<IntegrationResult<PullRequest[] | undefined>> {
13081303
const scope = getLogScope();
13091304
const connected = this.maybeConnected ?? (await this.isConnected());
13101305
if (!connected) return undefined;
@@ -1329,7 +1324,7 @@ export abstract class HostingIntegration<
13291324
repos?: T[],
13301325
cancellation?: CancellationToken,
13311326
silent?: boolean,
1332-
): Promise<SearchedPullRequest[] | undefined>;
1327+
): Promise<PullRequest[] | undefined>;
13331328

13341329
async searchPullRequests(
13351330
searchQuery: string,

src/plus/integrations/integrationService.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import type { Source } from '../../constants.telemetry';
1111
import { sourceToContext } from '../../constants.telemetry';
1212
import type { Container } from '../../container';
1313
import type { Account } from '../../git/models/author';
14-
import type { SearchedIssue } from '../../git/models/issue';
15-
import type { SearchedPullRequest } from '../../git/models/pullRequest';
14+
import type { IssueShape } from '../../git/models/issue';
15+
import type { PullRequest } from '../../git/models/pullRequest';
1616
import type { GitRemote } from '../../git/models/remote';
1717
import type { RemoteProvider, RemoteProviderId } from '../../git/remotes/remoteProvider';
1818
import { configuration } from '../../system/-webview/configuration';
@@ -726,7 +726,7 @@ export class IntegrationService implements Disposable {
726726
| SupportedSelfHostedIntegrationIds
727727
)[],
728728
options?: { openRepositoriesOnly?: boolean; cancellation?: CancellationToken },
729-
): Promise<SearchedIssue[] | undefined> {
729+
): Promise<IssueShape[] | undefined> {
730730
const integrations: Map<Integration, ResourceDescriptor[] | undefined> = new Map();
731731
const hostingIntegrationIds = integrationIds?.filter(
732732
id => id in HostingIntegrationId || id in SelfHostedIntegrationId,
@@ -796,8 +796,8 @@ export class IntegrationService implements Disposable {
796796
private async getMyIssuesCore(
797797
integrations: Map<Integration, ResourceDescriptor[] | undefined>,
798798
cancellation?: CancellationToken,
799-
): Promise<SearchedIssue[] | undefined> {
800-
const promises: Promise<SearchedIssue[] | undefined>[] = [];
799+
): Promise<IssueShape[] | undefined> {
800+
const promises: Promise<IssueShape[] | undefined>[] = [];
801801
for (const [integration, repos] of integrations) {
802802
if (integration == null) continue;
803803

@@ -808,12 +808,12 @@ export class IntegrationService implements Disposable {
808808
return [...flatten(filterMap(results, r => (r.status === 'fulfilled' ? r.value : undefined)))];
809809
}
810810

811-
async getMyIssuesForRemotes(remote: GitRemote): Promise<SearchedIssue[] | undefined>;
812-
async getMyIssuesForRemotes(remotes: GitRemote[]): Promise<SearchedIssue[] | undefined>;
811+
async getMyIssuesForRemotes(remote: GitRemote): Promise<IssueShape[] | undefined>;
812+
async getMyIssuesForRemotes(remotes: GitRemote[]): Promise<IssueShape[] | undefined>;
813813
@debug<IntegrationService['getMyIssuesForRemotes']>({
814814
args: { 0: (r: GitRemote | GitRemote[]) => (Array.isArray(r) ? r.map(rp => rp.name) : r.name) },
815815
})
816-
async getMyIssuesForRemotes(remoteOrRemotes: GitRemote | GitRemote[]): Promise<SearchedIssue[] | undefined> {
816+
async getMyIssuesForRemotes(remoteOrRemotes: GitRemote | GitRemote[]): Promise<IssueShape[] | undefined> {
817817
if (!Array.isArray(remoteOrRemotes)) {
818818
remoteOrRemotes = [remoteOrRemotes];
819819
}
@@ -874,7 +874,7 @@ export class IntegrationService implements Disposable {
874874
integrationIds?: (HostingIntegrationId | CloudSelfHostedIntegrationId)[],
875875
cancellation?: CancellationToken,
876876
silent?: boolean,
877-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>> {
877+
): Promise<IntegrationResult<PullRequest[] | undefined>> {
878878
const integrations: Map<HostingIntegration, ResourceDescriptor[] | undefined> = new Map();
879879
for (const integrationId of integrationIds?.length ? integrationIds : Object.values(HostingIntegrationId)) {
880880
let integration;
@@ -894,10 +894,10 @@ export class IntegrationService implements Disposable {
894894
integrations: Map<HostingIntegration, ResourceDescriptor[] | undefined>,
895895
cancellation?: CancellationToken,
896896
silent?: boolean,
897-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>> {
897+
): Promise<IntegrationResult<PullRequest[] | undefined>> {
898898
const start = Date.now();
899899

900-
const promises: Promise<IntegrationResult<SearchedPullRequest[] | undefined>>[] = [];
900+
const promises: Promise<IntegrationResult<PullRequest[] | undefined>>[] = [];
901901
for (const [integration, repos] of integrations) {
902902
if (integration == null) continue;
903903

@@ -932,16 +932,14 @@ export class IntegrationService implements Disposable {
932932
};
933933
}
934934

935-
async getMyPullRequestsForRemotes(remote: GitRemote): Promise<IntegrationResult<SearchedPullRequest[] | undefined>>;
936-
async getMyPullRequestsForRemotes(
937-
remotes: GitRemote[],
938-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>>;
935+
async getMyPullRequestsForRemotes(remote: GitRemote): Promise<IntegrationResult<PullRequest[] | undefined>>;
936+
async getMyPullRequestsForRemotes(remotes: GitRemote[]): Promise<IntegrationResult<PullRequest[] | undefined>>;
939937
@debug<IntegrationService['getMyPullRequestsForRemotes']>({
940938
args: { 0: (r: GitRemote | GitRemote[]) => (Array.isArray(r) ? r.map(rp => rp.name) : r.name) },
941939
})
942940
async getMyPullRequestsForRemotes(
943941
remoteOrRemotes: GitRemote | GitRemote[],
944-
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>> {
942+
): Promise<IntegrationResult<PullRequest[] | undefined>> {
945943
if (!Array.isArray(remoteOrRemotes)) {
946944
remoteOrRemotes = [remoteOrRemotes];
947945
}

src/plus/integrations/providers/azureDevOps.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ import { window } from 'vscode';
33
import { HostingIntegrationId } from '../../../constants.integrations';
44
import type { Account } from '../../../git/models/author';
55
import type { DefaultBranch } from '../../../git/models/defaultBranch';
6-
import type { Issue, SearchedIssue } from '../../../git/models/issue';
6+
import type { Issue, IssueShape } from '../../../git/models/issue';
77
import type { IssueOrPullRequest } from '../../../git/models/issueOrPullRequest';
8-
import type {
9-
PullRequest,
10-
PullRequestMergeMethod,
11-
PullRequestState,
12-
SearchedPullRequest,
13-
} from '../../../git/models/pullRequest';
8+
import type { PullRequest, PullRequestMergeMethod, PullRequestState } from '../../../git/models/pullRequest';
149
import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata';
1510
import { getSettledValue } from '../../../system/promise';
1611
import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider';
@@ -316,7 +311,7 @@ export class AzureDevOpsIntegration extends HostingIntegration<
316311
protected override async searchProviderMyPullRequests(
317312
session: AuthenticationSession,
318313
repos?: AzureRepositoryDescriptor[],
319-
): Promise<SearchedPullRequest[] | undefined> {
314+
): Promise<PullRequest[] | undefined> {
320315
const api = await this.getProvidersApi();
321316
if (repos != null) {
322317
// TODO: implement repos version
@@ -351,17 +346,15 @@ export class AzureDevOpsIntegration extends HostingIntegration<
351346
authorLogin: user.username,
352347
})
353348
)?.map(pr => this.fromAzureProviderPullRequest(pr, repoDescriptors, projects));
354-
const prsById = new Map<string, SearchedPullRequest>();
349+
const prsById = new Map<string, PullRequest>();
355350
for (const pr of authoredPrs ?? []) {
356-
prsById.set(pr.id, { pullRequest: pr, reasons: ['authored'] });
351+
prsById.set(pr.id, pr);
357352
}
358353

359354
for (const pr of assignedPrs ?? []) {
360355
const existing = prsById.get(pr.id);
361-
if (existing != null) {
362-
existing.reasons.push('assigned');
363-
} else {
364-
prsById.set(pr.id, { pullRequest: pr, reasons: ['assigned'] });
356+
if (existing == null) {
357+
prsById.set(pr.id, pr);
365358
}
366359
}
367360

@@ -371,7 +364,7 @@ export class AzureDevOpsIntegration extends HostingIntegration<
371364
protected override async searchProviderMyIssues(
372365
session: AuthenticationSession,
373366
_repos?: AzureRepositoryDescriptor[],
374-
): Promise<SearchedIssue[] | undefined> {
367+
): Promise<IssueShape[] | undefined> {
375368
const api = await this.getProvidersApi();
376369

377370
const user = await this.getProviderCurrentAccount(session);
@@ -410,18 +403,16 @@ export class AzureDevOpsIntegration extends HostingIntegration<
410403
)
411404
).flat();
412405
// TODO: Add mentioned issues
413-
const issuesById = new Map<string, SearchedIssue>();
406+
const issuesById = new Map<string, IssueShape>();
414407

415408
for (const issue of authoredIssues ?? []) {
416-
issuesById.set(issue.id, { issue: issue, reasons: ['authored'] });
409+
issuesById.set(issue.id, issue);
417410
}
418411

419412
for (const issue of assignedIssues ?? []) {
420413
const existing = issuesById.get(issue.id);
421-
if (existing != null) {
422-
existing.reasons.push('assigned');
423-
} else {
424-
issuesById.set(issue.id, { issue: issue, reasons: ['assigned'] });
414+
if (existing == null) {
415+
issuesById.set(issue.id, issue);
425416
}
426417
}
427418

src/plus/integrations/providers/bitbucket.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ import type { AuthenticationSession, CancellationToken } from 'vscode';
22
import { HostingIntegrationId } from '../../../constants.integrations';
33
import type { Account } from '../../../git/models/author';
44
import type { DefaultBranch } from '../../../git/models/defaultBranch';
5-
import type { Issue, SearchedIssue } from '../../../git/models/issue';
5+
import type { Issue, IssueShape } from '../../../git/models/issue';
66
import type { IssueOrPullRequest } from '../../../git/models/issueOrPullRequest';
7-
import type {
8-
PullRequest,
9-
PullRequestMergeMethod,
10-
PullRequestState,
11-
SearchedPullRequest,
12-
} from '../../../git/models/pullRequest';
7+
import type { PullRequest, PullRequestMergeMethod, PullRequestState } from '../../../git/models/pullRequest';
138
import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata';
149
import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider';
1510
import type { ResourceDescriptor } from '../integration';
@@ -126,14 +121,14 @@ export class BitbucketIntegration extends HostingIntegration<
126121
protected override async searchProviderMyPullRequests(
127122
_session: AuthenticationSession,
128123
_repos?: BitbucketRepositoryDescriptor[],
129-
): Promise<SearchedPullRequest[] | undefined> {
124+
): Promise<PullRequest[] | undefined> {
130125
return Promise.resolve(undefined);
131126
}
132127

133128
protected override async searchProviderMyIssues(
134129
_session: AuthenticationSession,
135130
_repos?: BitbucketRepositoryDescriptor[],
136-
): Promise<SearchedIssue[] | undefined> {
131+
): Promise<IssueShape[] | undefined> {
137132
return Promise.resolve(undefined);
138133
}
139134
}

src/plus/integrations/providers/github.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ import type { Sources } from '../../../constants.telemetry';
44
import type { Container } from '../../../container';
55
import type { Account, UnidentifiedAuthor } from '../../../git/models/author';
66
import type { DefaultBranch } from '../../../git/models/defaultBranch';
7-
import type { Issue, SearchedIssue } from '../../../git/models/issue';
7+
import type { Issue, IssueShape } from '../../../git/models/issue';
88
import type { IssueOrPullRequest } from '../../../git/models/issueOrPullRequest';
9-
import type {
10-
PullRequest,
11-
PullRequestMergeMethod,
12-
PullRequestState,
13-
SearchedPullRequest,
14-
} from '../../../git/models/pullRequest';
9+
import type { PullRequest, PullRequestMergeMethod, PullRequestState } from '../../../git/models/pullRequest';
1510
import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata';
1611
import type { PullRequestUrlIdentity } from '../../../git/utils/pullRequest.utils';
1712
import { log } from '../../../system/decorators/log';
@@ -190,7 +185,7 @@ abstract class GitHubIntegrationBase<ID extends SupportedIntegrationIds> extends
190185
repos?: GitHubRepositoryDescriptor[],
191186
cancellation?: CancellationToken,
192187
silent?: boolean,
193-
): Promise<SearchedPullRequest[] | undefined> {
188+
): Promise<PullRequest[] | undefined> {
194189
return (await this.container.github)?.searchMyPullRequests(
195190
this,
196191
accessToken,
@@ -207,7 +202,7 @@ abstract class GitHubIntegrationBase<ID extends SupportedIntegrationIds> extends
207202
{ accessToken }: AuthenticationSession,
208203
repos?: GitHubRepositoryDescriptor[],
209204
cancellation?: CancellationToken,
210-
): Promise<SearchedIssue[] | undefined> {
205+
): Promise<IssueShape[] | undefined> {
211206
return (await this.container.github)?.searchMyIssues(
212207
this,
213208
accessToken,

0 commit comments

Comments
 (0)