Skip to content

Commit ac989f5

Browse files
committed
Use only the version number for caching, remove duplication of cache key prefix asdf-vm#235
1 parent 44a45a4 commit ac989f5

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

install/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66920,17 +66920,18 @@ async function restoreAsdfCache() {
6692066920
});
6692166921
const toolVersionsHash = crypto4.createHash("sha256").update(toolVersions).digest("hex");
6692266922
core3.debug(`Tool versions hash: ${toolVersionsHash}`);
66923-
const asdfVersionOutput = await exec5.getExecOutput("asdf", ["--version"]);
66924-
const asdfVersion = asdfVersionOutput.stdout.trim().replace("asdf version", "");
66923+
const asdfVersionOutput = await exec5.getExecOutput("asdf", ["version"]);
66924+
const asdfVersion = asdfVersionOutput.stdout.trim();
6692566925
core3.debug(`asdf version: ${asdfVersion}`);
66926-
const cacheKey = `asdf-${asdfVersion}-${toolVersionsHash}`;
66926+
const cacheKeyPrefix = `asdf-${asdfVersion}-`;
66927+
const cacheKey = `${cacheKeyPrefix}${toolVersionsHash}`;
6692766928
core3.debug(`cache key: ${cacheKey}`);
6692866929
const paths = [
6692966930
`${process2.env.ASDF_DIR}/plugins`,
6693066931
`${process2.env.ASDF_DIR}/installs`
6693166932
];
6693266933
const restoreKeys = [
66933-
"asdf-tools-"
66934+
cacheKeyPrefix
6693466935
];
6693566936
core3.debug(`Restoring ${paths.join(", ")} from cache with key "${cacheKey}" using restore keys "${restoreKeys.join(", ")}"`);
6693666937
return cache.restoreCache(paths, cacheKey, restoreKeys);

src/install/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ async function restoreAsdfCache() {
1919

2020
core.debug(`Tool versions hash: ${toolVersionsHash}`);
2121

22-
const asdfVersionOutput = await exec.getExecOutput('asdf', ['--version']);
23-
const asdfVersion = asdfVersionOutput.stdout.trim().replace('asdf version', '');
22+
const asdfVersionOutput = await exec.getExecOutput('asdf', ['version']);
23+
const asdfVersion = asdfVersionOutput.stdout.trim();
2424

2525
core.debug(`asdf version: ${asdfVersion}`);
26-
const cacheKey = `asdf-${asdfVersion}-${toolVersionsHash}`;
26+
27+
const cacheKeyPrefix = `asdf-${asdfVersion}-`;
28+
const cacheKey = `${cacheKeyPrefix}${toolVersionsHash}`;
2729

2830
core.debug(`cache key: ${cacheKey}`);
2931

@@ -32,7 +34,7 @@ async function restoreAsdfCache() {
3234
`${process.env.ASDF_DIR!}/installs`,
3335
];
3436
const restoreKeys = [
35-
`asdf-tools-${asdfVersion}-`,
37+
cacheKeyPrefix,
3638
];
3739

3840
core.debug(`Restoring ${paths.join(', ')} from cache with key "${cacheKey}" using restore keys "${restoreKeys.join(', ')}"`);

0 commit comments

Comments
 (0)