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({
|
expect(repositoryCache.getCache()).toEqual({
|
||||||
repository: 'abc/def',
|
repository: 'abc/def',
|
||||||
scan: {},
|
revision: repositoryCache.CACHE_REVISION,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('reads from cache and finalizes', async () => {
|
it('reads from cache and finalizes', async () => {
|
||||||
|
@ -50,6 +50,6 @@ describe('lib/util/cache/repository', () => {
|
||||||
expect(fs.outputFile.mock.calls).toHaveLength(1);
|
expect(fs.outputFile.mock.calls).toHaveLength(1);
|
||||||
});
|
});
|
||||||
it('gets', () => {
|
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;
|
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> {
|
export async function initialize(config: RenovateConfig): Promise<void> {
|
||||||
cache = null;
|
cache = null;
|
||||||
try {
|
try {
|
||||||
|
@ -87,15 +94,11 @@ export async function initialize(config: RenovateConfig): Promise<void> {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.debug({ cacheFileName }, 'Repository cache not found');
|
logger.debug({ cacheFileName }, 'Repository cache not found');
|
||||||
}
|
}
|
||||||
cache = cache || Object.create({ revision: CACHE_REVISION });
|
cache ||= createCache(config.repository);
|
||||||
cache.repository = config.repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCache(): Cache {
|
export function getCache(): Cache {
|
||||||
cache = cache || Object.create({ revision: CACHE_REVISION });
|
return cache || createCache();
|
||||||
delete cache.init;
|
|
||||||
cache.scan = cache.scan || Object.create({});
|
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function finalize(): Promise<void> {
|
export async function finalize(): Promise<void> {
|
||||||
|
|
|
@ -55,7 +55,8 @@ export async function extract(
|
||||||
const baseBranchSha = getBranchCommit(baseBranch);
|
const baseBranchSha = getBranchCommit(baseBranch);
|
||||||
let packageFiles: Record<string, PackageFile[]>;
|
let packageFiles: Record<string, PackageFile[]>;
|
||||||
const cache = getCache();
|
const cache = getCache();
|
||||||
const cachedExtract = cache?.scan?.[baseBranch];
|
cache.scan ||= {};
|
||||||
|
const cachedExtract = cache.scan[baseBranch];
|
||||||
const configHash = hasha(JSON.stringify(config));
|
const configHash = hasha(JSON.stringify(config));
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in a new issue