mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(cache): skip save repo cache on dry-run (#19094)
This commit is contained in:
parent
325a11257d
commit
7603bebd03
2 changed files with 19 additions and 1 deletions
12
lib/util/cache/repository/index.spec.ts
vendored
12
lib/util/cache/repository/index.spec.ts
vendored
|
@ -36,6 +36,18 @@ describe('util/cache/repository/index', () => {
|
|||
expect(isCacheModified()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('skips saves cache on dry run', async () => {
|
||||
GlobalConfig.set({
|
||||
cacheDir: '/tmp/cache',
|
||||
platform: 'github',
|
||||
dryRun: true,
|
||||
});
|
||||
await initRepoCache({ ...config, repositoryCache: 'enabled' });
|
||||
await saveCache();
|
||||
expect(fs.outputCacheFile).not.toHaveBeenCalled();
|
||||
expect(isCacheModified()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('resets cache', async () => {
|
||||
await initRepoCache({ ...config, repositoryCache: 'reset' });
|
||||
expect(fs.readCacheFile).not.toHaveBeenCalled();
|
||||
|
|
6
lib/util/cache/repository/index.ts
vendored
6
lib/util/cache/repository/index.ts
vendored
|
@ -1,3 +1,5 @@
|
|||
import { GlobalConfig } from '../../../config/global';
|
||||
import { logger } from '../../../logger';
|
||||
import { RepoCacheNull } from './impl/null';
|
||||
import type { RepoCache, RepoCacheData } from './types';
|
||||
|
||||
|
@ -18,8 +20,12 @@ export function getCache(): RepoCacheData {
|
|||
}
|
||||
|
||||
export async function saveCache(): Promise<void> {
|
||||
if (GlobalConfig.get('dryRun')) {
|
||||
logger.info(`DRY-RUN: Would save repository cache.`);
|
||||
} else {
|
||||
await repoCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
export function isCacheModified(): boolean | undefined {
|
||||
return repoCache.isModified();
|
||||
|
|
Loading…
Reference in a new issue