Skip to content

Commit

Permalink
remove deleted issue from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Dec 31, 2024
1 parent 0152d27 commit 3fa1b53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/modules/platform/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,12 @@ export async function getIssue(number: number): Promise<Issue | null> {
GithubIssueCache.updateIssue(issue);
return issue;
} catch (err) /* istanbul ignore next */ {
logger.debug({ err, number }, 'Error getting issue');
logger.debug({ err, number: number }, 'Error getting issue');

Check failure on line 1250 in lib/modules/platform/github/index.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Expected property shorthand.
// istanbul ignore if
if (err.message === 'Response Code 410(Gone)') {
logger.debug(`Issue #${number} has been deleted`);
GithubIssueCache.deleteIssue(number);
}
return null;
}
}
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/platform/github/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export class GithubIssueCache {
}
}

static deleteIssue(number: number): void {
const cacheData = this.data;

Check warning on line 89 in lib/modules/platform/github/issue.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/platform/github/issue.ts#L89

Added line #L89 was not covered by tests
if (cacheData) {
delete cacheData[number];

Check warning on line 91 in lib/modules/platform/github/issue.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/platform/github/issue.ts#L91

Added line #L91 was not covered by tests
}
}

/**
* At the moment of repo initialization, repository cache is not available.
* What we can do is to store issues for later reconciliation.
Expand Down

0 comments on commit 3fa1b53

Please sign in to comment.