Skip to content

Commit 8276404

Browse files
committed
Fetches issue data for linear links in commit tooltips
(#4543, #4579)
1 parent 549f778 commit 8276404

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/autolinks/autolinksProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ export class AutolinksProvider implements Disposable {
178178
}
179179

180180
getAutolinkEnrichableId(autolink: Autolink): string {
181+
// TODO: this should return linking key for all types of providers: such as TST-123 or #89 or PR 89 (or a pair: key+id).
182+
// Each provider should form whatever ID they need in their specific getIssueOrPullRequest() method.
181183
switch (autolink.provider?.id) {
182184
case IssuesCloudHostIntegrationId.Jira:
185+
case IssuesCloudHostIntegrationId.Linear:
183186
return `${autolink.prefix}${autolink.id}`;
184187
default:
185188
return autolink.id;

src/plus/integrations/providers/linear.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Logger } from '../../../system/logger';
1010
import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider';
1111
import type { ProviderAuthenticationSession } from '../authentication/models';
1212
import { IssuesIntegration } from '../models/issuesIntegration';
13-
import type { IssueFilter } from './models';
13+
import type { IssueFilter, ProviderIssue } from './models';
1414
import { fromProviderIssue, providersMetadata, toIssueShape } from './models';
1515

1616
const metadata = providersMetadata[IssuesCloudHostIntegrationId.Linear];
@@ -210,19 +210,29 @@ export class LinearIntegration extends IssuesIntegration<IssuesCloudHostIntegrat
210210
}
211211
return issues;
212212
}
213-
protected override getProviderIssueOrPullRequest(
214-
_session: ProviderAuthenticationSession,
215-
_resource: ResourceDescriptor,
216-
_id: string,
213+
protected override async getProviderIssueOrPullRequest(
214+
session: ProviderAuthenticationSession,
215+
resource: ResourceDescriptor,
216+
id: string,
217217
_type: undefined | IssueOrPullRequestType,
218218
): Promise<IssueOrPullRequest | undefined> {
219-
throw new Error('Method not implemented.');
219+
const issue = await this.getRawProviderIssue(session, resource, id);
220+
return issue && toIssueShape(issue, this);
220221
}
221222
protected override async getProviderIssue(
222223
session: ProviderAuthenticationSession,
223224
resource: ResourceDescriptor,
224225
id: string,
225226
): Promise<Issue | undefined> {
227+
const result = await this.getRawProviderIssue(session, resource, id);
228+
return result && fromProviderIssue(result, this);
229+
}
230+
231+
private async getRawProviderIssue(
232+
session: ProviderAuthenticationSession,
233+
resource: ResourceDescriptor,
234+
id: string,
235+
): Promise<ProviderIssue | undefined> {
226236
const api = await this.getProvidersApi();
227237
try {
228238
if (!isIssueResourceDescriptor(resource)) {
@@ -243,7 +253,7 @@ export class LinearIntegration extends IssuesIntegration<IssuesCloudHostIntegrat
243253

244254
if (result == null) return undefined;
245255

246-
return fromProviderIssue(result, this);
256+
return result;
247257
} catch (ex) {
248258
Logger.error(ex, 'getProviderIssue');
249259
return undefined;

0 commit comments

Comments
 (0)