Skip to content

Commit 8c886db

Browse files
authored
Merge pull request #110 from beNative/codex/fix-commit-message-formatting
Trim leading whitespace from commit messages
2 parents 72b41ba + a1438ec commit 8c886db

3 files changed

Lines changed: 62 additions & 11 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 text-gray-900 dark:text-gray-100">
379+
<span className="block whitespace-pre-line"><HighlightedText text={sanitizedMessage} highlight={debouncedSearchQuery} /></span>
379380
</div>
380381
</div>
381382
</button>

components/modals/RepoFormModal.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,15 +1858,19 @@ interface CommitListItemProps {
18581858

18591859
const CommitListItem: React.FC<CommitListItemProps> = ({ commit, highlight }) => {
18601860
const commitHashTooltip = useTooltip(commit.hash);
1861+
const sanitizedMessage = commit.message.trimStart();
1862+
18611863
return (
18621864
<li className="p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700">
1863-
<pre className="font-sans whitespace-pre-wrap text-gray-900 dark:text-gray-100">
1864-
<HighlightedText text={commit.message} highlight={highlight} />
1865-
</pre>
1866-
<div className="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mt-2 pt-2 border-t border-gray-200 dark:border-gray-700">
1867-
<span>{commit.author}</span>
1868-
<span {...commitHashTooltip} className="font-mono">{commit.shortHash} &bull; {commit.date}</span>
1869-
</div>
1865+
<div className="font-sans text-gray-900 dark:text-gray-100">
1866+
<span className="block whitespace-pre-line leading-relaxed">
1867+
<HighlightedText text={sanitizedMessage} highlight={highlight} />
1868+
</span>
1869+
</div>
1870+
<div className="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mt-2 pt-2 border-t border-gray-200 dark:border-gray-700">
1871+
<span>{commit.author}</span>
1872+
<span {...commitHashTooltip} className="font-mono">{commit.shortHash} &bull; {commit.date}</span>
1873+
</div>
18701874
</li>
18711875
);
18721876
};
@@ -3539,7 +3543,11 @@ const RepoEditView: React.FC<RepoEditViewProps> = ({ onSave, onCancel, repositor
35393543
<p className="text-center text-gray-500">{debouncedHistorySearch ? `No commits found for "${debouncedHistorySearch}".` : 'No commits found.'}</p>
35403544
) : (
35413545
<>
3542-
{commits.map(commit => <CommitListItem key={commit.hash} commit={commit} highlight={debouncedHistorySearch} />)}
3546+
<ul className="space-y-3 list-none p-0 m-0">
3547+
{commits.map(commit => (
3548+
<CommitListItem key={commit.hash} commit={commit} highlight={debouncedHistorySearch} />
3549+
))}
3550+
</ul>
35433551
{hasMoreHistory && (
35443552
<div className="text-center">
35453553
<button onClick={() => fetchHistory(true)} disabled={isMoreHistoryLoading} className="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:bg-gray-500">

docs/history-tab-preview.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 text-gray-900">
22+
<span class="commit-message block whitespace-pre-line">Merge pull request #10 from beNative/codex/add-sqljs-support-and-configuration</span>
23+
</div>
24+
<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">
25+
<span>Tim Sinaeve</span>
26+
<span class="font-mono">7986e7f • 6 weeks ago</span>
27+
</div>
28+
</li>
29+
<li class="p-3 bg-gray-50 rounded-lg border border-gray-200">
30+
<div class="font-sans text-gray-900">
31+
<span class="commit-message block whitespace-pre-line">Use bundled sql.js assets for offline operation</span>
32+
</div>
33+
<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">
34+
<span>Tim Sinaeve</span>
35+
<span class="font-mono">44e8c63 • 6 weeks ago</span>
36+
</div>
37+
</li>
38+
</ul>
39+
</div>
40+
</div>
41+
</body>
42+
</html>

0 commit comments

Comments
 (0)