Skip to content

Commit 78876b7

Browse files
BytewaveMLPeregon
authored andcommitted
Use case-insensitive key comparsion for cache keys
1 parent 3ec1ec0 commit 78876b7

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

bundler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
206206
await exec.exec('bundle', ['install', '--jobs', '4'])
207207

208208
// @actions/cache only allows to save for non-existing keys
209-
if (cachedKey !== key) {
209+
if (!common.isExactKeyMatch(key, cachedKey)) {
210210
if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems
211211
await exec.exec('bundle', ['clean'])
212212
}

common.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,15 @@ export async function setupJavaHome(rubyPrefix) {
412412
}
413413
})
414414
}
415+
416+
// Determines if two keys are an exact match for the purposes of cache matching
417+
// Specifically, this is a case-insensitive match that ignores accents
418+
// From actions/cache@v3 src/utils/actionUtils.ts (MIT)
419+
export function isExactKeyMatch(key, cacheKey) {
420+
return !!(
421+
cacheKey &&
422+
cacheKey.localeCompare(key, undefined, {
423+
sensitivity: 'accent'
424+
}) === 0
425+
);
426+
}

dist/index.js

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)