From aea23c4fca0ad715720d870273f6b7bed1f5376b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 13 Jun 2020 12:58:38 -0700 Subject: [PATCH] do not save the cache if it was restored --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1d45918..bbb6a43 100644 --- a/index.js +++ b/index.js @@ -51,9 +51,11 @@ async function main() { const cachePaths = [path.join(os.homedir(), '.cache', 'pre-commit')]; const py = getPythonVersion(); 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}); - await cache.saveCache(cachePaths, cacheKey); + if (!restored) { + await cache.saveCache(cachePaths, cacheKey); + } if (ret && push) { // actions do not run on pushes made by actions.