Skip to content

Commit

Permalink
fix: correct separators in git log rename handling
Browse files Browse the repository at this point in the history
  • Loading branch information
John van Leeuwen committed Sep 29, 2024
1 parent 0f51904 commit aae727f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/backend/src/utils/git-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ function parseBodyEntry(
return bodyEntry;
}

// path.join replacement that does not depend on OS, and normalizes separators as used in a git log
function pathJoin(...args) {
return args.join('/').replace(/\/{2,}/g, '/').replace(/\/$/g, '');
}

function handleRenames(filePath: string, renameMap: Map<string, string>) {
const result = filePath.match(/(.*?)\{(.*?) => (.*?)\}(.*)/);

Expand All @@ -157,8 +162,8 @@ function handleRenames(filePath: string, renameMap: Map<string, string>) {
const after = result[3];
const end = result[4];

const from = path.join(start, before, end);
const to = path.join(start, after, end);
const from = pathJoin(start, before, end);
const to = pathJoin(start, after, end);

renameMap.set(from, renameMap.get(to) || to);
filePath = to;
Expand Down

0 comments on commit aae727f

Please sign in to comment.