@@ -73,7 +73,7 @@ import {
73
73
repoInfoQuery ,
74
74
vulnerabilityAlertsQuery ,
75
75
} from './graphql' ;
76
- import { GithubIssue as Issue } from './issue' ;
76
+ import { GithubIssueCache , GithubIssue as Issue } from './issue' ;
77
77
import { massageMarkdownLinks } from './massage-markdown-links' ;
78
78
import { getPrCache , updatePrCache } from './pr' ;
79
79
import type {
@@ -497,6 +497,7 @@ export async function initRepo({
497
497
variables : {
498
498
owner : config . repositoryOwner ,
499
499
name : config . repositoryName ,
500
+ user : renovateUsername ,
500
501
} ,
501
502
} ) ;
502
503
@@ -557,6 +558,11 @@ export async function initRepo({
557
558
config . autoMergeAllowed = repo . autoMergeAllowed ;
558
559
config . hasIssuesEnabled = repo . hasIssuesEnabled ;
559
560
config . hasVulnerabilityAlertsEnabled = repo . hasVulnerabilityAlertsEnabled ;
561
+
562
+ const recentIssues = Issue . array ( )
563
+ . catch ( [ ] )
564
+ . parse ( res ?. data ?. repository ?. issues ?. nodes ) ;
565
+ GithubIssueCache . addIssuesToReconcile ( recentIssues ) ;
560
566
} catch ( err ) /* istanbul ignore next */ {
561
567
logger . debug ( { err } , 'Caught initRepo error' ) ;
562
568
if (
@@ -591,7 +597,6 @@ export async function initRepo({
591
597
throw err ;
592
598
}
593
599
// This shouldn't be necessary, but occasional strange errors happened until it was added
594
- config . issueList = null ;
595
600
config . prList = null ;
596
601
597
602
if ( forkToken ) {
@@ -1221,17 +1226,16 @@ export async function getIssueList(): Promise<Issue[]> {
1221
1226
if ( config . hasIssuesEnabled === false ) {
1222
1227
return [ ] ;
1223
1228
}
1224
- if ( ! config . issueList ) {
1229
+ let issueList = GithubIssueCache . getIssues ( ) ;
1230
+ if ( ! issueList ) {
1225
1231
logger . debug ( 'Retrieving issueList' ) ;
1226
- config . issueList = await getIssues ( ) ;
1232
+ issueList = await getIssues ( ) ;
1233
+ GithubIssueCache . setIssues ( issueList ) ;
1227
1234
}
1228
- return config . issueList ;
1235
+ return issueList ;
1229
1236
}
1230
1237
1231
- export async function getIssue (
1232
- number : number ,
1233
- useCache = true ,
1234
- ) : Promise < Issue | null > {
1238
+ export async function getIssue ( number : number ) : Promise < Issue | null > {
1235
1239
// istanbul ignore if
1236
1240
if ( config . hasIssuesEnabled === false ) {
1237
1241
return null ;
@@ -1241,11 +1245,11 @@ export async function getIssue(
1241
1245
const { body : issue } = await githubApi . getJson (
1242
1246
`repos/${ repo } /issues/${ number } ` ,
1243
1247
{
1244
- memCache : useCache ,
1245
1248
cacheProvider : repoCacheProvider ,
1246
1249
} ,
1247
1250
Issue ,
1248
1251
) ;
1252
+ GithubIssueCache . updateIssue ( issue ) ;
1249
1253
return issue ;
1250
1254
} catch ( err ) /* istanbul ignore next */ {
1251
1255
logger . debug ( { err, number } , 'Error getting issue' ) ;
@@ -1267,12 +1271,13 @@ export async function findIssue(title: string): Promise<Issue | null> {
1267
1271
1268
1272
async function closeIssue ( issueNumber : number ) : Promise < void > {
1269
1273
logger . debug ( `closeIssue(${ issueNumber } )` ) ;
1270
- await githubApi . patchJson (
1271
- `repos/ ${ config . parentRepo ?? config . repository } /issues/ ${ issueNumber } ` ,
1272
- {
1273
- body : { state : 'closed' } ,
1274
- } ,
1274
+ const repo = config . parentRepo ?? config . repository ;
1275
+ const { body : closedIssue } = await githubApi . patchJson (
1276
+ `repos/ ${ repo } /issues/ ${ issueNumber } ` ,
1277
+ { body : { state : 'closed' } } ,
1278
+ Issue ,
1275
1279
) ;
1280
+ GithubIssueCache . updateIssue ( closedIssue ) ;
1276
1281
}
1277
1282
1278
1283
export async function ensureIssue ( {
@@ -1319,17 +1324,18 @@ export async function ensureIssue({
1319
1324
await closeIssue ( i . number ) ;
1320
1325
}
1321
1326
}
1327
+
1322
1328
const repo = config . parentRepo ?? config . repository ;
1323
- const {
1324
- body : { body : issueBody } ,
1325
- } = await githubApi . getJson (
1329
+ const { body : serverIssue } = await githubApi . getJson (
1326
1330
`repos/${ repo } /issues/${ issue . number } ` ,
1327
1331
{ cacheProvider : repoCacheProvider } ,
1328
1332
Issue ,
1329
1333
) ;
1334
+ GithubIssueCache . updateIssue ( serverIssue ) ;
1335
+
1330
1336
if (
1331
1337
issue . title === title &&
1332
- issueBody === body &&
1338
+ serverIssue . body === body &&
1333
1339
issue . state === 'open'
1334
1340
) {
1335
1341
logger . debug ( 'Issue is open and up to date - nothing to do' ) ;
@@ -1341,19 +1347,18 @@ export async function ensureIssue({
1341
1347
if ( labels ) {
1342
1348
data . labels = labels ;
1343
1349
}
1344
- await githubApi . patchJson (
1345
- `repos/${ config . parentRepo ?? config . repository } /issues/${
1346
- issue . number
1347
- } `,
1348
- {
1349
- body : data ,
1350
- } ,
1350
+ const repo = config . parentRepo ?? config . repository ;
1351
+ const { body : updatedIssue } = await githubApi . patchJson (
1352
+ `repos/${ repo } /issues/${ issue . number } ` ,
1353
+ { body : data } ,
1354
+ Issue ,
1351
1355
) ;
1356
+ GithubIssueCache . updateIssue ( updatedIssue ) ;
1352
1357
logger . debug ( 'Issue updated' ) ;
1353
1358
return 'updated' ;
1354
1359
}
1355
1360
}
1356
- await githubApi . postJson (
1361
+ const { body : createdIssue } = await githubApi . postJson (
1357
1362
`repos/${ config . parentRepo ?? config . repository } /issues` ,
1358
1363
{
1359
1364
body : {
@@ -1362,10 +1367,11 @@ export async function ensureIssue({
1362
1367
labels : labels ?? [ ] ,
1363
1368
} ,
1364
1369
} ,
1370
+ Issue ,
1365
1371
) ;
1366
1372
logger . info ( 'Issue created' ) ;
1367
1373
// reset issueList so that it will be fetched again as-needed
1368
- config . issueList = null ;
1374
+ GithubIssueCache . updateIssue ( createdIssue ) ;
1369
1375
return 'created' ;
1370
1376
} catch ( err ) /* istanbul ignore next */ {
1371
1377
if ( err . body ?. message ?. startsWith ( 'Issues are disabled for this repo' ) ) {
@@ -1410,13 +1416,14 @@ async function tryAddMilestone(
1410
1416
} ,
1411
1417
'Adding milestone to PR' ,
1412
1418
) ;
1413
- const repository = config . parentRepo ?? config . repository ;
1414
1419
try {
1415
- await githubApi . patchJson ( `repos/${ repository } /issues/${ issueNo } ` , {
1416
- body : {
1417
- milestone : milestoneNo ,
1418
- } ,
1419
- } ) ;
1420
+ const repo = config . parentRepo ?? config . repository ;
1421
+ const { body : updatedIssue } = await githubApi . patchJson (
1422
+ `repos/${ repo } /issues/${ issueNo } ` ,
1423
+ { body : { milestone : milestoneNo } } ,
1424
+ Issue ,
1425
+ ) ;
1426
+ GithubIssueCache . updateIssue ( updatedIssue ) ;
1420
1427
} catch ( err ) {
1421
1428
const actualError = err . response ?. body || /* istanbul ignore next */ err ;
1422
1429
logger . warn (
@@ -1436,11 +1443,12 @@ export async function addAssignees(
1436
1443
) : Promise < void > {
1437
1444
logger . debug ( `Adding assignees '${ assignees . join ( ', ' ) } ' to #${ issueNo } ` ) ;
1438
1445
const repository = config . parentRepo ?? config . repository ;
1439
- await githubApi . postJson ( `repos/${ repository } /issues/${ issueNo } /assignees` , {
1440
- body : {
1441
- assignees,
1442
- } ,
1443
- } ) ;
1446
+ const { body : updatedIssue } = await githubApi . postJson (
1447
+ `repos/${ repository } /issues/${ issueNo } /assignees` ,
1448
+ { body : { assignees } } ,
1449
+ Issue ,
1450
+ ) ;
1451
+ GithubIssueCache . updateIssue ( updatedIssue ) ;
1444
1452
}
1445
1453
1446
1454
export async function addReviewers (
0 commit comments