From 307ebe8e8438af8ee805ed65a21bb334a56eb63b Mon Sep 17 00:00:00 2001 From: Abner <22141172+Silentely@users.noreply.github.com> Date: Mon, 18 May 2026 20:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore:=20=E7=A7=BB=E9=99=A4=20pr?= =?UTF-8?q?e-commit=20=E4=B8=AD=E7=9A=84=E8=BF=9C=E7=A8=8B=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/pre-commit-check.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/scripts/pre-commit-check.js b/scripts/pre-commit-check.js index ec110aa..f56aefd 100644 --- a/scripts/pre-commit-check.js +++ b/scripts/pre-commit-check.js @@ -68,39 +68,6 @@ function getTouchedProtectedFiles() { return output.split('\0').filter(Boolean); } -function getUpstreamRef() { - try { - return git([ - 'rev-parse', - '--abbrev-ref', - '--symbolic-full-name', - '@{u}' - ]).trim(); - } catch (_) { - return ''; - } -} - -function syncWithRemote() { - const upstreamRef = getUpstreamRef(); - if (!upstreamRef) { - console.log('ℹ️ 当前分支未配置 upstream,跳过远程同步'); - return; - } - - console.log(`🔄 提交前同步远程更新(${upstreamRef})...`); - try { - git(['pull', '--rebase', '--autostash', '--quiet'], { - stdio: 'inherit' - }); - console.log('✅ 远程更新同步完成'); - } catch (_) { - console.error('\n❌ pre-commit 远程同步失败:'); - console.error(' - 请先手动执行 `git pull --rebase` 解决冲突后再提交。'); - process.exit(1); - } -} - function shouldFormat(relPath) { const ext = path.extname(relPath).toLowerCase(); if (TEXT_EXTENSIONS.has(ext)) { @@ -221,8 +188,6 @@ function main() { process.exit(1); } - syncWithRemote(); - const stagedFiles = getStagedFiles(); if (stagedFiles.length === 0) { process.exit(0);