Skip to content

Commit 470aac6

Browse files
committed
Wrapped saving pre-commit cache to cache, in a try catch block
1 parent 763fbaf commit 470aac6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ async function main() {
5454
const restored = await cache.restoreCache(cachePaths, cacheKey);
5555
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
5656
if (!restored) {
57-
await cache.saveCache(cachePaths, cacheKey);
57+
try {
58+
await cache.saveCache(cachePaths, cacheKey);
59+
} catch (e) {
60+
core.warning(
61+
[
62+
"There was an error saving the pre-commit environments to cache:\n\n",
63+
`${e.message}\n\n`,
64+
"This only has performance implications and won't change the result of your pre-commit tests.\n",
65+
"If this problem persists on your default branch, you can try to fix it by editing your '.pre-commit-config.yaml'. ",
66+
"I.e. run 'pre-commit autoupdate' or simply add a blank line. ",
67+
"This will result in a different hash value and thus a different cache target.",
68+
].join("")
69+
);
70+
}
5871
}
5972

6073
if (ret && push) {

0 commit comments

Comments
 (0)