Skip to content

Commit

Permalink
chore: add test-case for fixed rename handling
Browse files Browse the repository at this point in the history
  • Loading branch information
John van Leeuwen committed Sep 30, 2024
1 parent 15d2e7c commit 7765af7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion apps/backend/src/services/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export function inferFolders(options: Options): Folder[] {
}
}

const converted = toFolder(root);
let converted = toFolder(root);
while (
converted.folders.length === 1 &&
converted.folders[0].folders.length === 1
)
converted = converted.folders[0];
return converted.folders;
}
6 changes: 6 additions & 0 deletions apps/backend/src/utils/git-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const logWithRenames = `"John Doe <[email protected]>,${today.toISOString()}"
"Jane Doe <[email protected]>,${today.toISOString()}"
10\t0\t/shell/my.component.ts
0\t1\t/shell/my-other.component.ts
20\t1\t/shared/feature-checkin/my.component.ts
`;

jest.mock('../infrastructure/log');
Expand Down Expand Up @@ -506,6 +507,11 @@ describe('git parser', () => {
linesRemoved: 1,
path: '/shell/my-other.component.ts',
},
{
linesAdded: 20,
linesRemoved: 1,
path: '/shared/sub-features/feature-checkin/my.component.ts',
},
],
},
]);
Expand Down
5 changes: 4 additions & 1 deletion apps/backend/src/utils/git-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ function parseBodyEntry(

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

function handleRenames(filePath: string, renameMap: Map<string, string>) {
Expand Down

0 comments on commit 7765af7

Please sign in to comment.