@@ -4,10 +4,12 @@ import { Commands } from '../../constants.commands';
44import type { StoredDeepLinkContext , StoredNamedRef } from '../../constants.storage' ;
55import type { Container } from '../../container' ;
66import { executeGitCommand } from '../../git/actions' ;
7- import { openFileAtRevision } from '../../git/actions/commit' ;
7+ import { openComparisonChanges , openFileAtRevision } from '../../git/actions/commit' ;
88import type { GitBranch } from '../../git/models/branch' ;
99import { getBranchNameWithoutRemote } from '../../git/models/branch' ;
1010import type { GitCommit } from '../../git/models/commit' ;
11+ import type { PullRequest } from '../../git/models/pullRequest' ;
12+ import { getComparisonRefsForPullRequest } from '../../git/models/pullRequest' ;
1113import type { GitReference } from '../../git/models/reference' ;
1214import { createReference , isSha } from '../../git/models/reference' ;
1315import type { Repository , RepositoryChangeEvent } from '../../git/models/repository' ;
@@ -19,6 +21,7 @@ import { missingRepositoryId } from '../../gk/models/repositoryIdentities';
1921import { ensureAccount , ensurePaidPlan } from '../../plus/utils' ;
2022import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol' ;
2123import { createQuickPickSeparator } from '../../quickpicks/items/common' ;
24+ import { debug } from '../../system/decorators/log' ;
2225import { once } from '../../system/event' ;
2326import { Logger } from '../../system/logger' ;
2427import { normalizePath } from '../../system/path' ;
@@ -68,10 +71,7 @@ export class DeepLinkService implements Disposable {
6871 this . _disposables . push ( container . uri . onDidReceiveUri ( async ( uri : Uri ) => this . processDeepLinkUri ( uri ) ) ) ;
6972
7073 const pendingDeepLink = this . container . storage . get ( 'deepLinks:pending' ) ;
71- if ( pendingDeepLink != null ) {
72- void this . container . storage . delete ( 'deepLinks:pending' ) ;
73- void this . processPendingDeepLink ( pendingDeepLink ) ;
74- }
74+ void this . processPendingDeepLink ( pendingDeepLink ) ;
7575 }
7676
7777 dispose ( ) {
@@ -114,6 +114,7 @@ export class DeepLinkService implements Disposable {
114114 targetId : link . targetId ,
115115 secondaryTargetId : link . secondaryTargetId ,
116116 secondaryRemoteUrl : link . secondaryRemoteUrl ,
117+ prId : link . prId ,
117118 action : link . action ,
118119 params : link . params ,
119120 } ;
@@ -241,8 +242,10 @@ export class DeepLinkService implements Disposable {
241242 }
242243 }
243244
244- private async processPendingDeepLink ( pendingDeepLink : StoredDeepLinkContext ) {
245- if ( pendingDeepLink . url == null ) return ;
245+ @debug ( )
246+ private async processPendingDeepLink ( pendingDeepLink : StoredDeepLinkContext | undefined ) {
247+ if ( pendingDeepLink ?. url == null ) return ;
248+ void this . container . storage . delete ( 'deepLinks:pending' ) ;
246249
247250 const link = parseDeepLinkUri ( Uri . parse ( pendingDeepLink . url ) ) ;
248251 if ( link == null ) return ;
@@ -312,6 +315,19 @@ export class DeepLinkService implements Disposable {
312315 return repo . git . getBranch ( targetId ) ;
313316 }
314317
318+ private async getPullRequest ( targetId : string ) : Promise < PullRequest | undefined > {
319+ const { repo, remote } = this . _context ;
320+ if ( ! repo ) return undefined ;
321+ const pullRequests = remote
322+ ? await this . container . integrations . getMyPullRequestsForRemotes ( remote )
323+ : await this . container . integrations . getMyPullRequests ( ) ;
324+
325+ if ( ! pullRequests ?. value ) {
326+ return ;
327+ }
328+ return pullRequests . value . find ( x => x . pullRequest . id === targetId ) ?. pullRequest ;
329+ }
330+
315331 private async getCommit ( targetId : string ) : Promise < GitCommit | undefined > {
316332 const { repo } = this . _context ;
317333 if ( ! repo ) return undefined ;
@@ -509,6 +525,7 @@ export class DeepLinkService implements Disposable {
509525 // TODO @axosoft -ramint: Move all the logic for matching a repo, prompting to add repo, matching remote, etc. for a target (branch, PR, etc.)
510526 // to a separate service where it can be used outside of the context of deep linking. Then the deep link service should leverage it,
511527 // and we should stop using deep links to process things like Launchpad switch actions, Open in Worktree command, etc.
528+ @debug ( )
512529 private async processDeepLink (
513530 initialAction : DeepLinkServiceAction = DeepLinkServiceAction . DeepLinkEventFired ,
514531 useProgress : boolean = true ,
@@ -1373,7 +1390,6 @@ export class DeepLinkService implements Disposable {
13731390 case DeepLinkServiceState . OpenInspect : {
13741391 // If we arrive at this step, clear any stored data used for the "new window" option
13751392 await this . container . storage . delete ( 'deepLinks:pending' ) ;
1376-
13771393 if ( ! repo ) {
13781394 action = DeepLinkServiceAction . DeepLinkErrored ;
13791395 message = 'Missing repository.' ;
@@ -1386,6 +1402,25 @@ export class DeepLinkService implements Disposable {
13861402 repository : repo ,
13871403 source : 'launchpad' ,
13881404 } satisfies ShowWipArgs ) ;
1405+ if ( this . _context . prId ) {
1406+ action = DeepLinkServiceAction . OpenAllPrChanges ;
1407+ } else {
1408+ action = DeepLinkServiceAction . DeepLinkResolved ;
1409+ }
1410+ break ;
1411+ }
1412+ case DeepLinkServiceState . OpenAllPrChanges : {
1413+ const pr = await this . getPullRequest ( this . _context . prId ! ) ;
1414+ const refs = getComparisonRefsForPullRequest ( this . _context . repoPath ! , pr ! . refs ! ) ;
1415+ await openComparisonChanges (
1416+ this . container ,
1417+ {
1418+ repoPath : refs . repoPath ,
1419+ lhs : refs . base . ref ,
1420+ rhs : refs . head . ref ,
1421+ } ,
1422+ { title : `Changes in Pull Request "${ pr ! . title } "` } ,
1423+ ) ;
13891424 action = DeepLinkServiceAction . DeepLinkResolved ;
13901425 break ;
13911426 }
0 commit comments