mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(cache): correct revision
This commit is contained in:
parent
9171e712d4
commit
728082b3c3
3 changed files with 13 additions and 9 deletions
4
lib/util/cache/repository/index.spec.ts
vendored
4
lib/util/cache/repository/index.spec.ts
vendored
|
@ -34,7 +34,7 @@ describe('lib/util/cache/repository', () => {
|
|||
});
|
||||
expect(repositoryCache.getCache()).toEqual({
|
||||
repository: 'abc/def',
|
||||
scan: {},
|
||||
revision: repositoryCache.CACHE_REVISION,
|
||||
});
|
||||
});
|
||||
it('reads from cache and finalizes', async () => {
|
||||
|
@ -50,6 +50,6 @@ describe('lib/util/cache/repository', () => {
|
|||
expect(fs.outputFile.mock.calls).toHaveLength(1);
|
||||
});
|
||||
it('gets', () => {
|
||||
expect(repositoryCache.getCache()).toEqual({ scan: {} });
|
||||
expect(repositoryCache.getCache()).toEqual({});
|
||||
});
|
||||
});
|
||||
|
|
15
lib/util/cache/repository/index.ts
vendored
15
lib/util/cache/repository/index.ts
vendored
|
@ -73,6 +73,13 @@ function validate(config: RenovateConfig, input: any): Cache | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
function createCache(repository?: string): Cache {
|
||||
const res: Cache = Object.create({});
|
||||
res.repository = repository;
|
||||
res.revision = CACHE_REVISION;
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function initialize(config: RenovateConfig): Promise<void> {
|
||||
cache = null;
|
||||
try {
|
||||
|
@ -87,15 +94,11 @@ export async function initialize(config: RenovateConfig): Promise<void> {
|
|||
} catch (err) {
|
||||
logger.debug({ cacheFileName }, 'Repository cache not found');
|
||||
}
|
||||
cache = cache || Object.create({ revision: CACHE_REVISION });
|
||||
cache.repository = config.repository;
|
||||
cache ||= createCache(config.repository);
|
||||
}
|
||||
|
||||
export function getCache(): Cache {
|
||||
cache = cache || Object.create({ revision: CACHE_REVISION });
|
||||
delete cache.init;
|
||||
cache.scan = cache.scan || Object.create({});
|
||||
return cache;
|
||||
return cache || createCache();
|
||||
}
|
||||
|
||||
export async function finalize(): Promise<void> {
|
||||
|
|
|
@ -55,7 +55,8 @@ export async function extract(
|
|||
const baseBranchSha = getBranchCommit(baseBranch);
|
||||
let packageFiles: Record<string, PackageFile[]>;
|
||||
const cache = getCache();
|
||||
const cachedExtract = cache?.scan?.[baseBranch];
|
||||
cache.scan ||= {};
|
||||
const cachedExtract = cache.scan[baseBranch];
|
||||
const configHash = hasha(JSON.stringify(config));
|
||||
// istanbul ignore if
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue