1
1
// import type { EnrichedAutolink } from './annotations/autolinks';
2
2
import type { Disposable } from './api/gitlens' ;
3
+ import type { AutolinkType } from './autolinks/models/autolinks' ;
3
4
import type { Container } from './container' ;
4
5
import type { Account } from './git/models/author' ;
5
6
import type { DefaultBranch } from './git/models/defaultBranch' ;
@@ -111,6 +112,7 @@ export class CacheProvider implements Disposable {
111
112
112
113
getIssueOrPullRequest (
113
114
id : string ,
115
+ type : AutolinkType | undefined ,
114
116
resource : ResourceDescriptor ,
115
117
integration : IntegrationBase | undefined ,
116
118
cacheable : Cacheable < IssueOrPullRequest > ,
@@ -119,11 +121,11 @@ export class CacheProvider implements Disposable {
119
121
const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
120
122
121
123
if ( resource == null ) {
122
- return this . get ( 'issuesOrPrsById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
124
+ return this . get ( 'issuesOrPrsById' , `id:${ id } :${ key } : ${ type ?? 'unknown' } ` , etag , cacheable , options ) ;
123
125
}
124
126
return this . get (
125
127
'issuesOrPrsByIdAndRepo' ,
126
- `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` ,
128
+ `id:${ id } :${ key } :${ type ?? 'unknown' } : ${ JSON . stringify ( resource ) } }` ,
127
129
etag ,
128
130
cacheable ,
129
131
options ,
@@ -140,11 +142,17 @@ export class CacheProvider implements Disposable {
140
142
const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
141
143
142
144
if ( resource == null ) {
143
- return this . get ( 'issuesById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
145
+ return this . get (
146
+ 'issuesById' ,
147
+ `id:${ id } :${ key } :${ 'issue' satisfies AutolinkType } ` ,
148
+ etag ,
149
+ cacheable ,
150
+ options ,
151
+ ) ;
144
152
}
145
153
return this . get (
146
154
'issuesByIdAndResource' ,
147
- `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` ,
155
+ `id:${ id } :${ key } :${ 'issue' satisfies AutolinkType } : ${ JSON . stringify ( resource ) } }` ,
148
156
etag ,
149
157
cacheable ,
150
158
options ,
@@ -161,9 +169,21 @@ export class CacheProvider implements Disposable {
161
169
const { key, etag } = getResourceKeyAndEtag ( resource , integration ) ;
162
170
163
171
if ( resource == null ) {
164
- return this . get ( 'prsById' , `id:${ id } :${ key } ` , etag , cacheable , options ) ;
172
+ return this . get (
173
+ 'prsById' ,
174
+ `id:${ id } :${ key } :${ 'pullrequest' satisfies AutolinkType } ` ,
175
+ etag ,
176
+ cacheable ,
177
+ options ,
178
+ ) ;
165
179
}
166
- return this . get ( 'prsById' , `id:${ id } :${ key } :${ JSON . stringify ( resource ) } }` , etag , cacheable , options ) ;
180
+ return this . get (
181
+ 'prsById' ,
182
+ `id:${ id } :${ key } :${ 'pullrequest' satisfies AutolinkType } :${ JSON . stringify ( resource ) } }` ,
183
+ etag ,
184
+ cacheable ,
185
+ options ,
186
+ ) ;
167
187
}
168
188
169
189
getPullRequestForBranch (
@@ -264,7 +284,12 @@ export class CacheProvider implements Disposable {
264
284
if ( isPromise ( item . value ) ) {
265
285
void item . value . then ( v => {
266
286
if ( v != null ) {
267
- this . set ( 'issuesOrPrsById' , `id:${ v . id } :${ key } ` , v , etag ) ;
287
+ this . set (
288
+ 'issuesOrPrsById' ,
289
+ `id:${ v . id } :${ key } :${ 'pullrequest' satisfies AutolinkType } ` ,
290
+ v ,
291
+ etag ,
292
+ ) ;
268
293
}
269
294
} ) ;
270
295
}
0 commit comments