Merged origin/master into Update new branch styling

This commit is contained in:
Pavel Laptev 2024-01-05 12:00:29 +01:00 committed by GitButler
commit 2c9270eee9

View File

@ -16,8 +16,10 @@ export function computedAddedRemoved(...files: File[]) {
} }
export function computeFileStatus(file: File): FileStatus { export function computeFileStatus(file: File): FileStatus {
const { added, removed } = computedAddedRemoved(file); if (file.hunks.length == 1) {
// TODO: How should we handle this for binary files? See: https://git-scm.com/docs/git-status const diff = file.hunks[0].diff;
const contentLineCount = file.content?.trim().split('\n').length; if (/^@@ -0,0 /.test(diff)) return 'A';
return added == contentLineCount ? 'A' : removed == contentLineCount ? 'D' : 'M'; if (/^@@ -\d+,\d+ \+0,0/.test(diff)) return 'D';
}
return 'M';
} }