Skip to content

Commit aae727f

Browse files
author
John van Leeuwen
committed
fix: correct separators in git log rename handling
1 parent 0f51904 commit aae727f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/backend/src/utils/git-parser.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ function parseBodyEntry(
148148
return bodyEntry;
149149
}
150150

151+
// path.join replacement that does not depend on OS, and normalizes separators as used in a git log
152+
function pathJoin(...args) {
153+
return args.join('/').replace(/\/{2,}/g, '/').replace(/\/$/g, '');
154+
}
155+
151156
function handleRenames(filePath: string, renameMap: Map<string, string>) {
152157
const result = filePath.match(/(.*?)\{(.*?) => (.*?)\}(.*)/);
153158

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

160-
const from = path.join(start, before, end);
161-
const to = path.join(start, after, end);
165+
const from = pathJoin(start, before, end);
166+
const to = pathJoin(start, after, end);
162167

163168
renameMap.set(from, renameMap.get(to) || to);
164169
filePath = to;

0 commit comments

Comments
 (0)