Skip to content

Commit

Permalink
fix: don't do "delete only" for keys with type info in them
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jul 3, 2024
1 parent 8e16b25 commit fa90725
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/shared/local/moveDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ const compareHashes = ({ addedMap, deletedMap }: AddAndDeleteMaps): StringMapsFo
if (addedMap.size && deletedMap.size) {
// the remaining deletes didn't match the basename+hash of an add, and vice versa.
// They *might* match the basename of an add, in which case we *could* have the "move, then edit" case.
const addedBasenameMap = new Map([...addedMap.entries()].map(hashEntryToBasenameEntry));
const deletedBasenameMap = new Map([...deletedMap.entries()].map(hashEntryToBasenameEntry));
// the entry might be sha,basename OR sha,basename,type,parent
const addedBasenameMap = new Map(
[...addedMap.entries()].filter(hashEntryHasNoTypeInformation).map(hashEntryToBasenameEntry)
);
const deletedBasenameMap = new Map(
[...deletedMap.entries()].filter(hashEntryHasNoTypeInformation).map(hashEntryToBasenameEntry)
);
const deleteOnly = new Map<string, string>(
Array.from(deletedBasenameMap.entries())
.filter(([k]) => addedBasenameMap.has(k))
Expand Down Expand Up @@ -289,6 +294,7 @@ const toKey = (input: FilenameBasenameHash): string => `${input.hash}${JOIN_CHAR

const hashEntryToBasenameEntry = ([k, v]: [string, string]): [string, string] => [hashToBasename(k), v];
const hashToBasename = (hash: string): string => hash.split(JOIN_CHAR)[1];
const hashEntryHasNoTypeInformation = ([k]: [string, string]): boolean => k.split(JOIN_CHAR).length === 2;

const getResolverForFilenames =
(registry: RegistryAccess) =>
Expand Down

0 comments on commit fa90725

Please sign in to comment.