diff --git a/cptr/frontend/src/lib/components/GitView.svelte b/cptr/frontend/src/lib/components/GitView.svelte
index 99b7ca1..15ee85b 100644
--- a/cptr/frontend/src/lib/components/GitView.svelte
+++ b/cptr/frontend/src/lib/components/GitView.svelte
@@ -6,7 +6,7 @@
import { tooltip } from '$lib/tooltip';
import { t } from '$lib/i18n';
- import type { DiffFile } from '$lib/utils/diff';
+ import { countDiffStats, type DiffFile } from '$lib/utils/diff';
import Icon from './Icon.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import DiffSettingsMenu from './DiffSettingsMenu.svelte';
@@ -34,6 +34,8 @@
const workspacePath = $derived($activeWorkspace?.path ?? '');
const totalChanges = $derived(reviewFiles.length);
+ const totalAdditions = $derived(reviewFiles.reduce((sum, file) => sum + file.additions, 0));
+ const totalDeletions = $derived(reviewFiles.reduce((sum, file) => sum + file.deletions, 0));
const anyExpanded = $derived(reviewFiles.some((file) => file.expanded));
// React to git status changes from centralized store
@@ -89,7 +91,7 @@
diffFiles = [];
}
- const counts = countDiff(diffFiles);
+ const counts = countDiffStats(diffFiles);
const key = fileKey(file);
return {
key,
@@ -126,20 +128,6 @@
return `${file.staged ? 'staged' : 'unstaged'}:${file.status}:${file.path}`;
}
- function countDiff(files: DiffFile[]): { additions: number; deletions: number } {
- let additions = 0;
- let deletions = 0;
- for (const file of files) {
- for (const hunk of file.hunks) {
- for (const line of hunk.lines) {
- if (line.type === 'added') additions += 1;
- if (line.type === 'removed') deletions += 1;
- }
- }
- }
- return { additions, deletions };
- }
-
function toggleFile(key: string) {
reviewFiles = reviewFiles.map((file) =>
file.key === key ? { ...file, expanded: !file.expanded } : file
@@ -162,27 +150,6 @@
if (slash < 0) return { dir: '', name: path };
return { dir: path.slice(0, slash + 1), name: path.slice(slash + 1) };
}
-
- function statusMeta(status: string): { char: string; label: string; className: string } {
- switch (status) {
- case 'added':
- return { char: 'A', label: 'Added', className: 'text-green-600 dark:text-green-400' };
- case 'untracked':
- return { char: 'U', label: 'Untracked', className: 'text-green-600 dark:text-green-400' };
- case 'modified':
- return { char: 'M', label: 'Modified', className: 'text-amber-500 dark:text-amber-400' };
- case 'deleted':
- return { char: 'D', label: 'Deleted', className: 'text-red-500 dark:text-red-400' };
- case 'renamed':
- return { char: 'R', label: 'Renamed', className: 'text-blue-500 dark:text-blue-400' };
- case 'copied':
- return { char: 'C', label: 'Copied', className: 'text-blue-500 dark:text-blue-400' };
- case 'conflict':
- return { char: '!', label: 'Conflict', className: 'text-orange-500 dark:text-orange-400' };
- default:
- return { char: '?', label: status, className: 'text-gray-400 dark:text-gray-500' };
- }
- }
{$t('git.changedCount', { count: totalChanges })}
+ +{totalAdditions}
+ -{totalDeletions}
{/if}
@@ -279,6 +252,12 @@
{$t('git.change', { count: totalChanges })}
+
+{totalAdditions}
+
-{totalDeletions}