@@ -56,13 +56,13 @@ export class DeepLinkService implements Disposable {
5656 return ;
5757 }
5858
59- if ( link . type !== DeepLinkType . Repository && ! link . targetId ) {
59+ if ( link . type !== DeepLinkType . Repository && link . targetId == null ) {
6060 void window . showErrorMessage ( 'Unable to resolve link' ) ;
6161 Logger . warn ( `Unable to resolve link - no target id provided: ${ uri . toString ( ) } ` ) ;
6262 return ;
6363 }
6464
65- if ( link . type === DeepLinkType . Comparison && ! link . secondaryTargetId ) {
65+ if ( link . type === DeepLinkType . Comparison && link . secondaryTargetId == null ) {
6666 void window . showErrorMessage ( 'Unable to resolve link' ) ;
6767 Logger . warn ( `Unable to resolve link - no secondary target id provided: ${ uri . toString ( ) } ` ) ;
6868 return ;
@@ -187,16 +187,21 @@ export class DeepLinkService implements Disposable {
187187 targetId : string ,
188188 secondaryTargetId : string ,
189189 ) : Promise < [ string , string ] | undefined > {
190- // try treating each id as a commit sha first, then a branch if that fails, then a tag if that fails
190+ // try treating each id as a commit sha first, then a branch if that fails, then a tag if that fails.
191+ // Note: a blank target id will be treated as 'Working Tree' and will resolve to a blank Sha.
191192 const sha1 =
192- ( await this . getShaForCommit ( targetId ) ) ??
193- ( await this . getShaForBranch ( targetId ) ) ??
194- ( await this . getShaForTag ( targetId ) ) ;
193+ targetId === ''
194+ ? targetId
195+ : ( await this . getShaForCommit ( targetId ) ) ??
196+ ( await this . getShaForBranch ( targetId ) ) ??
197+ ( await this . getShaForTag ( targetId ) ) ;
195198 if ( sha1 == null ) return undefined ;
196199 const sha2 =
197- ( await this . getShaForCommit ( secondaryTargetId ) ) ??
198- ( await this . getShaForBranch ( secondaryTargetId ) ) ??
199- ( await this . getShaForTag ( secondaryTargetId ) ) ;
200+ secondaryTargetId === ''
201+ ? secondaryTargetId
202+ : ( await this . getShaForCommit ( secondaryTargetId ) ) ??
203+ ( await this . getShaForBranch ( secondaryTargetId ) ) ??
204+ ( await this . getShaForTag ( secondaryTargetId ) ) ;
200205 if ( sha2 == null ) return undefined ;
201206 return [ sha1 , sha2 ] ;
202207 }
@@ -663,18 +668,18 @@ export class DeepLinkService implements Disposable {
663668 break ;
664669 }
665670
666- if ( ! targetSha || ! secondaryTargetSha ) {
671+ if ( targetSha == null || secondaryTargetSha == null ) {
667672 action = DeepLinkServiceAction . DeepLinkErrored ;
668673 message = 'Missing target or secondary target.' ;
669674 break ;
670675 }
671676
672677 await this . container . searchAndCompareView . compare (
673678 repo . path ,
674- isSha ( secondaryTargetSha )
679+ secondaryTargetSha === '' || isSha ( secondaryTargetSha )
675680 ? secondaryTargetSha
676681 : { label : secondaryTargetSha , ref : secondaryTargetSha } ,
677- isSha ( targetSha ) ? targetSha : { label : targetSha , ref : targetSha } ,
682+ targetSha === '' || isSha ( targetSha ) ? targetSha : { label : targetSha , ref : targetSha } ,
678683 ) ;
679684 action = DeepLinkServiceAction . DeepLinkResolved ;
680685 break ;
0 commit comments