From c4e0ef33ab66e4701a9ee4e4a9415ec5b60db712 Mon Sep 17 00:00:00 2001 From: wonder Date: Fri, 19 Jun 2026 22:40:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=93=E5=BA=93=E9=A1=B5=E9=9D=A2=20r?= =?UTF-8?q?ef=20=E9=80=89=E6=8B=A9=E5=99=A8=E5=A1=AB=E5=85=85=E6=9C=80?= =?UTF-8?q?=E8=BF=91=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/pages/repo.html | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/pages/repo.html b/templates/pages/repo.html index daefca7..a178a1f 100644 --- a/templates/pages/repo.html +++ b/templates/pages/repo.html @@ -168,7 +168,15 @@ const refsResp = await fetch(`/api/repos/${repoId}/refs`); if (refsResp.ok) { currentRefs = await refsResp.json(); - populateRefSelects(currentRefs); + + // Fetch recent commits independently + let commits = []; + try { + const graphResp = await fetch(`/api/repos/${repoId}/graph?max_commits=20`); + if (graphResp.ok) commits = await graphResp.json(); + } catch (e) { /* ignore */ } + + populateRefSelects(currentRefs, commits); updateButtonLinks(); } @@ -195,7 +203,7 @@ document.getElementById('error-message').textContent = message; } - function populateRefSelects(refs) { + function populateRefSelects(refs, commits) { const selects = ['select-base', 'select-head']; const branches = refs.filter(r => !r.is_tag); const tags = refs.filter(r => r.is_tag); @@ -231,10 +239,10 @@ } // Add "Recent Commits" group - if (GitGraph.commits && GitGraph.commits.length > 0) { + if (commits && commits.length > 0) { const group = document.createElement('optgroup'); group.label = '最近提交'; - GitGraph.commits.slice(0, 20).forEach(commit => { + commits.forEach(commit => { const opt = document.createElement('option'); opt.value = commit.hash; opt.dataset.hash = commit.hash;