Skip to content

Commit 767948d

Browse files
committed
Use case-insensitive key comparsion for cache keys
1 parent 7bae1d0 commit 767948d

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

bundler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
209209
await exec.exec('bundle', ['install', '--jobs', '4'])
210210

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

common.js

+12
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,15 @@ export function setupPath(newPathEntries) {
393393
core.addPath(newPath.join(path.delimiter))
394394
return msys2Type
395395
}
396+
397+
// Determines if two keys are an exact match for the purposes of cache matching
398+
// Specifically, this is a case-insensitive match that ignores accents
399+
// From actions/cache@v3 src/utils/actionUtils.ts (MIT)
400+
export function isExactKeyMatch(key, cacheKey) {
401+
return !!(
402+
cacheKey &&
403+
cacheKey.localeCompare(key, undefined, {
404+
sensitivity: 'accent'
405+
}) === 0
406+
);
407+
}

dist/index.js

+15-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)