|
1 | 1 | import type { CancellationToken, ColorTheme, ConfigurationChangeEvent, Uri } from 'vscode'; |
2 | 2 | import { CancellationTokenSource, Disposable, env, window } from 'vscode'; |
| 3 | +import { Autolink } from '../../../annotations/autolinks'; |
3 | 4 | import type { CreatePullRequestActionContext, OpenPullRequestActionContext } from '../../../api/gitlens'; |
4 | 5 | import { getAvatarUri } from '../../../avatars'; |
5 | 6 | import { parseCommandContext } from '../../../commands/base'; |
@@ -98,7 +99,7 @@ import { gate } from '../../../system/decorators/gate'; |
98 | 99 | import { debug, log } from '../../../system/decorators/log'; |
99 | 100 | import type { Deferrable } from '../../../system/function'; |
100 | 101 | import { debounce, disposableInterval } from '../../../system/function'; |
101 | | -import { count, find, last, map } from '../../../system/iterable'; |
| 102 | +import { count, find, flatMap, last, map } from '../../../system/iterable'; |
102 | 103 | import { updateRecordValue } from '../../../system/object'; |
103 | 104 | import { |
104 | 105 | getSettledValue, |
@@ -2354,26 +2355,38 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph |
2354 | 2355 | const branch = getSettledValue(branchResult); |
2355 | 2356 | if (branch != null) { |
2356 | 2357 | branchState = { ...branch.state }; |
| 2358 | + const [remoteResult] = await Promise.allSettled([branch.getRemote()]); |
| 2359 | + const remote = getSettledValue(remoteResult); |
| 2360 | + |
| 2361 | + if (remote?.provider != null) { |
| 2362 | + branchState.provider = { |
| 2363 | + name: remote.provider.name, |
| 2364 | + icon: remote.provider.icon === 'remote' ? 'cloud' : remote.provider.icon, |
| 2365 | + url: remote.provider.url({ type: RemoteResourceType.Repo }), |
| 2366 | + }; |
| 2367 | + } |
| 2368 | + const autolinks = await this.container.autolinks.getAutolinks(branch.name, remote, { |
| 2369 | + isBranchName: true, |
| 2370 | + }); |
| 2371 | + if (autolinks.size) { |
| 2372 | + const tm = new Map<string, string>(); |
| 2373 | + branchState.issueLinks = [ |
| 2374 | + ...flatMap(autolinks, ([, { url, id, prefix, title, type, tokenize }]) => [ |
| 2375 | + { url: url, type: type, title: tokenize?.(id, 'markdown', tm) ?? prefix + id, tooltip: title }, |
| 2376 | + ]), |
| 2377 | + ]; |
| 2378 | + console.log({ tm: tm }); |
| 2379 | + } |
2357 | 2380 |
|
2358 | 2381 | if (branch.upstream != null) { |
2359 | 2382 | branchState.upstream = branch.upstream.name; |
2360 | 2383 |
|
2361 | 2384 | const cancellation = this.createCancellation('state'); |
2362 | 2385 |
|
2363 | | - const [remoteResult, prResult] = await Promise.allSettled([ |
2364 | | - branch.getRemote(), |
| 2386 | + const [prResult] = await Promise.allSettled([ |
2365 | 2387 | pauseOnCancelOrTimeout(branch.getAssociatedPullRequest(), cancellation.token, 100), |
2366 | 2388 | ]); |
2367 | 2389 |
|
2368 | | - const remote = getSettledValue(remoteResult); |
2369 | | - if (remote?.provider != null) { |
2370 | | - branchState.provider = { |
2371 | | - name: remote.provider.name, |
2372 | | - icon: remote.provider.icon === 'remote' ? 'cloud' : remote.provider.icon, |
2373 | | - url: remote.provider.url({ type: RemoteResourceType.Repo }), |
2374 | | - }; |
2375 | | - } |
2376 | | - |
2377 | 2390 | const maybePr = getSettledValue(prResult); |
2378 | 2391 | if (maybePr?.paused) { |
2379 | 2392 | const updatedBranchState = { ...branchState }; |
|
0 commit comments