5
0
Fork 0
mirror of https://github.com/pre-commit/action.git synced 2025-11-07 10:46:56 +00:00

do not save the cache if it was restored

This commit is contained in:
Anthony Sottile 2020-06-13 12:58:38 -07:00
parent 5c843d930a
commit aea23c4fca

View file

@ -51,9 +51,11 @@ async function main() {
const cachePaths = [path.join(os.homedir(), '.cache', 'pre-commit')]; const cachePaths = [path.join(os.homedir(), '.cache', 'pre-commit')];
const py = getPythonVersion(); const py = getPythonVersion();
const cacheKey = `pre-commit-2-${hashString(py)}-${hashFile('.pre-commit-config.yaml')}`; const cacheKey = `pre-commit-2-${hashString(py)}-${hashFile('.pre-commit-config.yaml')}`;
await cache.restoreCache(cachePaths, cacheKey); const restored = await cache.restoreCache(cachePaths, cacheKey);
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push}); const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
await cache.saveCache(cachePaths, cacheKey); if (!restored) {
await cache.saveCache(cachePaths, cacheKey);
}
if (ret && push) { if (ret && push) {
// actions do not run on pushes made by actions. // actions do not run on pushes made by actions.