🔧 chore: 移除 pre-commit 中的远程同步逻辑

This commit is contained in:
Abner
2026-05-18 20:18:46 +08:00
parent 3148a3564c
commit 307ebe8e84

View File

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