diff --git a/lib/util/cache/repository/common.ts b/lib/util/cache/repository/common.ts index 11cb26a26ae614ec1d30e68d49309b4e60bee8db..eb31e922424ac7796822c5f5e975fcbb1f759f8a 100644 --- a/lib/util/cache/repository/common.ts +++ b/lib/util/cache/repository/common.ts @@ -1,5 +1,9 @@ import is from '@sindresorhus/is'; -import type { RepoCacheData, RepoCacheRecord } from './types'; +import type { + RepoCacheRecordV10, + RepoCacheRecordV11, + RepoCacheRecordV12, +} from './types'; // Increment this whenever there could be incompatibilities between old and new cache structure export const CACHE_REVISION = 12; @@ -7,7 +11,7 @@ export const CACHE_REVISION = 12; export function isValidRev10( input: unknown, repo?: string -): input is RepoCacheData & { repository?: string; revision?: number } { +): input is RepoCacheRecordV10 { return ( is.plainObject(input) && is.safeInteger(input.revision) && @@ -20,7 +24,7 @@ export function isValidRev10( export function isValidRev11( input: unknown, repo?: string -): input is { repository: string; revision: number; data: RepoCacheData } { +): input is RepoCacheRecordV11 { return ( is.plainObject(input) && is.safeInteger(input.revision) && @@ -34,7 +38,7 @@ export function isValidRev11( export function isValidRev12( input: unknown, repo?: string -): input is RepoCacheRecord { +): input is RepoCacheRecordV12 { return ( is.plainObject(input) && is.safeInteger(input.revision) && diff --git a/lib/util/cache/repository/types.ts b/lib/util/cache/repository/types.ts index ceda2315f9d013f99d8446df002e99e89c90d0e5..3a24bab188ee298ec73d76d2efe180f26088d409 100644 --- a/lib/util/cache/repository/types.ts +++ b/lib/util/cache/repository/types.ts @@ -47,13 +47,26 @@ export interface RepoCacheData { prComments?: Record<number, Record<string, string>>; } -export interface RepoCacheRecord { +export interface RepoCacheRecordV10 extends RepoCacheData { + repository?: string; + revision?: number; +} + +export interface RepoCacheRecordV11 { + repository: string; + revision: number; + data: RepoCacheData; +} + +export interface RepoCacheRecordV12 { repository: string; revision: number; payload: string; hash: string; } +export type RepoCacheRecord = RepoCacheRecordV12; + export interface RepoCache { load(): Promise<void>; save(): Promise<void>;