Skip to content

Commit be84d09

Browse files
committed
Trim leading whitespace from commit messages
1 parent 97abb27 commit be84d09

2 files changed

Lines changed: 53 additions & 3 deletions

File tree

components/modals/CommitHistoryModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ const CommitHistoryModal: React.FC<CommitHistoryModalProps> = ({ isOpen, reposit
345345
<p className="text-center text-gray-500">{debouncedSearchQuery ? `No commits found for "${debouncedSearchQuery}".` : 'No commits found.'}</p>
346346
) : (
347347
<>
348-
<ul className="space-y-3">
348+
<ul className="space-y-3 list-none p-0">
349349
{commits.map(commit => {
350350
const isExpanded = expandedCommits.has(commit.hash);
351351
const diffFiles = diffCache[commit.hash] || [];
@@ -362,6 +362,7 @@ const CommitHistoryModal: React.FC<CommitHistoryModalProps> = ({ isOpen, reposit
362362
const noFilesMessage = diffFiles.length === 0 && filter === 'all'
363363
? 'No files changed in this commit.'
364364
: 'No files match the selected filter.';
365+
const sanitizedMessage = commit.message.trimStart();
365366

366367
return (
367368
<li key={commit.hash} className="p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700">
@@ -374,8 +375,8 @@ const CommitHistoryModal: React.FC<CommitHistoryModalProps> = ({ isOpen, reposit
374375
{isExpanded ? <ChevronDownIcon className="h-5 w-5" /> : <ChevronRightIcon className="h-5 w-5" />}
375376
</span>
376377
<div className="flex-1">
377-
<div className="font-sans whitespace-pre-wrap text-gray-900 dark:text-gray-100">
378-
<HighlightedText text={commit.message} highlight={debouncedSearchQuery} />
378+
<div className="font-sans whitespace-pre-line text-gray-900 dark:text-gray-100">
379+
<HighlightedText text={sanitizedMessage} highlight={debouncedSearchQuery} />
379380
</div>
380381
</div>
381382
</button>

docs/history-tab-preview.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>History Tab Preview</title>
7+
<script src="https://cdn.tailwindcss.com"></script>
8+
</head>
9+
<body class="bg-gray-100 min-h-screen flex items-start justify-center p-10">
10+
<div class="bg-white shadow-xl rounded-lg max-w-3xl w-full">
11+
<div class="p-4 border-b flex items-center gap-3">
12+
<div class="bg-blue-100 text-blue-600 rounded-full h-10 w-10 flex items-center justify-center font-bold">H</div>
13+
<div>
14+
<h1 class="text-xl font-bold">Commit History</h1>
15+
<p class="text-sm text-gray-500">for 'git-automation'</p>
16+
</div>
17+
</div>
18+
<div class="p-4">
19+
<ul class="space-y-3 list-none p-0">
20+
<li class="p-3 bg-gray-50 rounded-lg border border-gray-200">
21+
<div class="font-sans whitespace-pre-line text-gray-900 commit-message">
22+
23+
Merge pull request #10 from beNative/codex/add-sqljs-support-and-configuration
24+
</div>
25+
<div class="flex flex-col gap-2 text-xs text-gray-500 mt-2 pt-2 border-t border-gray-200 sm:flex-row sm:items-center sm:justify-between">
26+
<span>Tim Sinaeve</span>
27+
<span class="font-mono">7986e7f • 6 weeks ago</span>
28+
</div>
29+
</li>
30+
<li class="p-3 bg-gray-50 rounded-lg border border-gray-200">
31+
<div class="font-sans whitespace-pre-line text-gray-900 commit-message">
32+
33+
Use bundled sql.js assets for offline operation
34+
</div>
35+
<div class="flex flex-col gap-2 text-xs text-gray-500 mt-2 pt-2 border-t border-gray-200 sm:flex-row sm:items-center sm:justify-between">
36+
<span>Tim Sinaeve</span>
37+
<span class="font-mono">44e8c63 • 6 weeks ago</span>
38+
</div>
39+
</li>
40+
</ul>
41+
</div>
42+
</div>
43+
<script>
44+
document.querySelectorAll('.commit-message').forEach((el) => {
45+
el.textContent = el.textContent.trimStart();
46+
});
47+
</script>
48+
</body>
49+
</html>

0 commit comments

Comments
 (0)