mirror of
https://github.com/yamadashy/repomix.git
synced 2026-05-30 11:18:53 +02:00
86a4208f02
GitHub auto-links 7+ char commit SHAs in PR comments, but wrapping them in <code> HTML tags prevented this. Remove the tags so SHAs become clickable links automatically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
/**
|
|
* Escape HTML special characters for safe embedding in comments.
|
|
*/
|
|
export const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
|
|
/**
|
|
* Extract benchmark history JSON embedded in an HTML comment.
|
|
*/
|
|
export function extractHistory(body) {
|
|
const jsonMatch = body.match(/<!-- bench-history-json-start ([\s\S]*?) bench-history-json-end -->/);
|
|
if (!jsonMatch) return [];
|
|
try {
|
|
return JSON.parse(jsonMatch[1]);
|
|
} catch (e) {
|
|
console.error('Failed to parse benchmark history:', e);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Render history entries as collapsible HTML.
|
|
*/
|
|
export function renderHistory(hist) {
|
|
if (hist.length === 0) return '';
|
|
return hist
|
|
.map((h) => {
|
|
const label = `${h.sha}${h.msg ? ` ${h.msg}` : ''}`;
|
|
const osRows = ['ubuntu', 'macos', 'windows']
|
|
.filter((os) => h[os] && h[os] !== '-')
|
|
.map((os) => {
|
|
const osLabel = os === 'ubuntu' ? 'Ubuntu' : os === 'macos' ? 'macOS' : 'Windows';
|
|
return `<tr><td><strong>${osLabel}:</strong></td><td>${h[os]}</td></tr>`;
|
|
})
|
|
.join('\n');
|
|
return `${label}\n<table>\n${osRows}\n</table>`;
|
|
})
|
|
.join('\n\n');
|
|
}
|