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);