feat(ui): Git 面板列表头显示 remote
列表只有仓库路径和分支,看不出这个仓库推到哪、也没法一眼确认有没有配远端。 ensureRepo 多读一条 git remote -v(取第一条 fetch,origin 惯例在最前), URL 里的 user:pass 先脱敏再给前端;列表头渲染成「路径 · 分支 · origin」, 悬停看完整地址,没配 remote 时灰色标「无 remote」。
This commit is contained in:
+9
-1
@@ -47,7 +47,15 @@ async function ensureRepo(dir) {
|
||||
let head = '';
|
||||
try { branch = (await run(root, ['symbolic-ref', '--short', '-q', 'HEAD'])).trim(); } catch (_) { /* detached */ }
|
||||
try { head = (await run(root, ['rev-parse', '--short', 'HEAD'])).trim(); } catch (_) { /* 空仓库 */ }
|
||||
return { root, branch: branch || (head ? 'detached' : ''), head };
|
||||
// remote:列表里要能看出这个仓库推到哪。只取第一条 fetch(origin 惯例在最前);
|
||||
// URL 里的 user:pass 脱敏,免得面板上直接暴露凭据。
|
||||
let remote = null;
|
||||
try {
|
||||
const first = (await run(root, ['remote', '-v'])).split('\n').filter(Boolean)[0] || '';
|
||||
const m = /^(\S+)\s+(\S+)\s+\(fetch\)/.exec(first);
|
||||
if (m) remote = { name: m[1], url: m[2].replace(/\/\/[^/@]+@/, '//***@') };
|
||||
} catch (_) { /* 没配 remote */ }
|
||||
return { root, branch: branch || (head ? 'detached' : ''), head, remote };
|
||||
}
|
||||
|
||||
// 把一个整段 diff 按 `diff --git` 切开,键是文件路径。
|
||||
|
||||
@@ -1923,6 +1923,9 @@ body.pv-max .pv-code { max-width: none; padding-left: 16px; padding-right: 16px;
|
||||
.vcs-repo { padding: 9px 16px; border-bottom: 1px solid var(--border); background: var(--drawer-bg);
|
||||
font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--gray);
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
/* 列表头里的 remote 名:悬停看 URL(已脱敏);没配 remote 时灰色注明 */
|
||||
.vcs-repo .vcs-remote { color: var(--fg-0550ae); cursor: help; }
|
||||
.vcs-repo .vcs-remote.none { color: var(--gray); }
|
||||
.vcs-empty { padding: 44px 24px; text-align: center; font-size: 13px; color: var(--gray-light); }
|
||||
.vcs-item { padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
|
||||
.vcs-item:hover { background: var(--surface); }
|
||||
|
||||
@@ -54,7 +54,10 @@
|
||||
const parts = [];
|
||||
parts.push('<div class="vcs-list">');
|
||||
if (st.repo) {
|
||||
parts.push('<div class="vcs-repo">' + esc(st.repo.root) + (st.repo.branch ? ' · ' + esc(st.repo.branch) : '') + '</div>');
|
||||
const rm = st.repo.remote;
|
||||
parts.push('<div class="vcs-repo">' + esc(st.repo.root) + (st.repo.branch ? ' · ' + esc(st.repo.branch) : '') +
|
||||
' · <span class="vcs-remote' + (rm ? '' : ' none') + '" title="' + esc(rm ? rm.url : '未配置 remote') + '">' +
|
||||
esc(rm ? rm.name : '无 remote') + '</span></div>');
|
||||
}
|
||||
if (st.worktree && st.worktree.files) {
|
||||
parts.push('<div class="vcs-item wt" data-act="worktree">' +
|
||||
|
||||
Reference in New Issue
Block a user