From db876f4c9ca1727094d7c1256caa6687821c5df8 Mon Sep 17 00:00:00 2001 From: dsh-go Date: Tue, 17 Nov 2026 13:11:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BB=93=E5=BA=93=E5=89=8D?= =?UTF-8?q?=E5=85=88=E6=8E=A2=E6=B5=8B=E6=98=AF=E5=90=A6=E5=B7=B2=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=EF=BC=8C=E9=81=BF=E5=BC=80=E4=BA=8C=E6=AC=A1=E9=99=90?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由 dsh-go 自动上传 · 2026/11/17 13:11:35 --- lib/github.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/github.js b/lib/github.js index 43acbfb..cbbe714 100644 --- a/lib/github.js +++ b/lib/github.js @@ -58,6 +58,16 @@ export async function getLogin(token) { /** 保证仓库存在;已存在就复用。返回 { url, cloneUrl, created }。 */ export async function ensureRepo({ token, login, name, privateRepo = true, description = '' }) { + // 先问一下仓库在不在:已经推过一次的项目不必每次都调创建接口, + // 也避开 GitHub 对「内容创建」的二次限流(那个档位下 POST 会被 403)。 + try { + const existing = await request(`/repos/${login}/${name}`, { token }) + if (existing && existing.html_url) { + return { url: existing.html_url, cloneUrl: existing.clone_url, created: false } + } + } catch (error) { + if (!(error instanceof GitHubError) || error.status !== 404) throw error + } try { const repo = await request('/user/repos', { token,