Skip to content

Commit b1299d9

Browse files
committed
Match git line counting
1 parent 8f1a1d8 commit b1299d9

File tree

1 file changed

+5
-1
lines changed
  • apps/array/src/main/services

1 file changed

+5
-1
lines changed

apps/array/src/main/services/git.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const fsPromises = fs.promises;
1616
const countFileLines = async (filePath: string): Promise<number> => {
1717
try {
1818
const content = await fsPromises.readFile(filePath, "utf-8");
19-
return content.split("\n").length;
19+
if (!content) return 0;
20+
21+
// Match git line counting: do not count trailing newline as extra line
22+
const lines = content.split("\n");
23+
return lines[lines.length - 1] === "" ? lines.length - 1 : lines.length;
2024
} catch {
2125
return 0;
2226
}

0 commit comments

Comments
 (0)